aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2011-09-17 00:20:45 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2011-09-18 20:34:16 +0200
commitaf09313eac20e91e7e70336c3b8a45688a73d146 (patch)
tree0b731e2b25bb0307af0e47433a3f535451461b36
parentac41a083efd64d94dfb15845c6c25ba5667ba8b8 (diff)
downloadlibssh-af09313eac20e91e7e70336c3b8a45688a73d146.tar.gz
libssh-af09313eac20e91e7e70336c3b8a45688a73d146.tar.xz
libssh-af09313eac20e91e7e70336c3b8a45688a73d146.zip
crypto: rename crypto_struct -> ssh_cipher_struct
-rw-r--r--include/libssh/crypto.h12
-rw-r--r--include/libssh/libcrypto.h2
-rw-r--r--include/libssh/libgcrypt.h2
-rw-r--r--src/crypt.c4
-rw-r--r--src/libcrypto.c34
-rw-r--r--src/libgcrypt.c30
-rw-r--r--src/wrapper.c14
7 files changed, 49 insertions, 49 deletions
diff --git a/include/libssh/crypto.h b/include/libssh/crypto.h
index 5f301ff2..dfdcac90 100644
--- a/include/libssh/crypto.h
+++ b/include/libssh/crypto.h
@@ -70,7 +70,7 @@ struct ssh_crypto_struct {
unsigned char *encryptMAC;
unsigned char *decryptMAC;
unsigned char hmacbuf[EVP_MAX_MD_SIZE];
- struct crypto_struct *in_cipher, *out_cipher; /* the cipher structures/objects */
+ struct ssh_cipher_struct *in_cipher, *out_cipher; /* the cipher structures/objects */
ssh_string server_pubkey;
const char *server_pubkey_type;
int do_compress_out; /* idem */
@@ -87,7 +87,7 @@ struct ssh_crypto_struct {
enum ssh_mac_e mac_type; /* Mac operations to use for key gen */
};
-struct crypto_struct {
+struct ssh_cipher_struct {
const char *name; /* ssh name of the algorithm */
unsigned int blocksize; /* blocksize of the algo */
unsigned int keylen; /* length of the key structure */
@@ -99,11 +99,11 @@ struct crypto_struct {
#endif
unsigned int keysize; /* bytes of key used. != keylen */
/* sets the new key for immediate use */
- int (*set_encrypt_key)(struct crypto_struct *cipher, void *key, void *IV);
- int (*set_decrypt_key)(struct crypto_struct *cipher, void *key, void *IV);
- void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,
+ int (*set_encrypt_key)(struct ssh_cipher_struct *cipher, void *key, void *IV);
+ int (*set_decrypt_key)(struct ssh_cipher_struct *cipher, void *key, void *IV);
+ void (*cbc_encrypt)(struct ssh_cipher_struct *cipher, void *in, void *out,
unsigned long len);
- void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,
+ void (*cbc_decrypt)(struct ssh_cipher_struct *cipher, void *in, void *out,
unsigned long len);
};
diff --git a/include/libssh/libcrypto.h b/include/libssh/libcrypto.h
index f1986602..8ddeac97 100644
--- a/include/libssh/libcrypto.h
+++ b/include/libssh/libcrypto.h
@@ -72,7 +72,7 @@ SHA256CTX sha256_init(void);
void sha256_update(SHA256CTX c, const void *data, unsigned long len);
void sha256_final(unsigned char *md, SHA256CTX c);
-struct crypto_struct *ssh_get_ciphertab(void);
+struct ssh_cipher_struct *ssh_get_ciphertab(void);
#endif /* HAVE_LIBCRYPTO */
diff --git a/include/libssh/libgcrypt.h b/include/libssh/libgcrypt.h
index 65545555..c4b0dc00 100644
--- a/include/libssh/libgcrypt.h
+++ b/include/libssh/libgcrypt.h
@@ -62,6 +62,6 @@ typedef gcry_mpi_t bignum;
#endif /* HAVE_LIBGCRYPT */
-struct crypto_struct *ssh_get_ciphertab(void);
+struct ssh_cipher_struct *ssh_get_ciphertab(void);
#endif /* LIBGCRYPT_H_ */
diff --git a/src/crypt.c b/src/crypt.c
index daeb70ed..5acb126a 100644
--- a/src/crypt.c
+++ b/src/crypt.c
@@ -61,7 +61,7 @@ uint32_t packet_decrypt_len(ssh_session session, char *crypted){
}
int packet_decrypt(ssh_session session, void *data,uint32_t len) {
- struct crypto_struct *crypto = session->current_crypto->in_cipher;
+ struct ssh_cipher_struct *crypto = session->current_crypto->in_cipher;
char *out = NULL;
if(len % session->current_crypto->in_cipher->blocksize != 0){
ssh_set_error(session, SSH_FATAL, "Cryptographic functions must be set on at least one blocksize (received %d)",len);
@@ -90,7 +90,7 @@ int packet_decrypt(ssh_session session, void *data,uint32_t len) {
}
unsigned char *packet_encrypt(ssh_session session, void *data, uint32_t len) {
- struct crypto_struct *crypto = NULL;
+ struct ssh_cipher_struct *crypto = NULL;
HMACCTX ctx = NULL;
char *out = NULL;
unsigned int finallen;
diff --git a/src/libcrypto.c b/src/libcrypto.c
index 02491030..747994ef 100644
--- a/src/libcrypto.c
+++ b/src/libcrypto.c
@@ -65,7 +65,7 @@ struct ssh_mac_ctx_struct {
} ctx;
};
-static int alloc_key(struct crypto_struct *cipher) {
+static int alloc_key(struct ssh_cipher_struct *cipher) {
cipher->key = malloc(cipher->keylen);
if (cipher->key == NULL) {
return -1;
@@ -234,7 +234,7 @@ void hmac_final(HMACCTX ctx, unsigned char *hashmacbuf, unsigned int *len) {
#ifdef HAS_BLOWFISH
/* the wrapper functions for blowfish */
-static int blowfish_set_key(struct crypto_struct *cipher, void *key, void *IV){
+static int blowfish_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV){
if (cipher->key == NULL) {
if (alloc_key(cipher) < 0) {
return -1;
@@ -245,19 +245,19 @@ static int blowfish_set_key(struct crypto_struct *cipher, void *key, void *IV){
return 0;
}
-static void blowfish_encrypt(struct crypto_struct *cipher, void *in,
+static void blowfish_encrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
BF_cbc_encrypt(in, out, len, cipher->key, cipher->IV, BF_ENCRYPT);
}
-static void blowfish_decrypt(struct crypto_struct *cipher, void *in,
+static void blowfish_decrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
BF_cbc_encrypt(in, out, len, cipher->key, cipher->IV, BF_DECRYPT);
}
#endif /* HAS_BLOWFISH */
#ifdef HAS_AES
-static int aes_set_encrypt_key(struct crypto_struct *cipher, void *key,
+static int aes_set_encrypt_key(struct ssh_cipher_struct *cipher, void *key,
void *IV) {
if (cipher->key == NULL) {
if (alloc_key(cipher) < 0) {
@@ -271,7 +271,7 @@ static int aes_set_encrypt_key(struct crypto_struct *cipher, void *key,
cipher->IV=IV;
return 0;
}
-static int aes_set_decrypt_key(struct crypto_struct *cipher, void *key,
+static int aes_set_decrypt_key(struct ssh_cipher_struct *cipher, void *key,
void *IV) {
if (cipher->key == NULL) {
if (alloc_key(cipher) < 0) {
@@ -286,12 +286,12 @@ static int aes_set_decrypt_key(struct crypto_struct *cipher, void *key,
return 0;
}
-static void aes_encrypt(struct crypto_struct *cipher, void *in, void *out,
+static void aes_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
unsigned long len) {
AES_cbc_encrypt(in, out, len, cipher->key, cipher->IV, AES_ENCRYPT);
}
-static void aes_decrypt(struct crypto_struct *cipher, void *in, void *out,
+static void aes_decrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
unsigned long len) {
AES_cbc_encrypt(in, out, len, cipher->key, cipher->IV, AES_DECRYPT);
}
@@ -306,7 +306,7 @@ static void aes_decrypt(struct crypto_struct *cipher, void *in, void *out,
* the size of the CTR counter and incidentally the blocksize, but not the keysize.
* @param len[in] must be a multiple of AES128 block size.
*/
-static void aes_ctr128_encrypt(struct crypto_struct *cipher, void *in, void *out,
+static void aes_ctr128_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
unsigned long len) {
unsigned char tmp_buffer[128/8];
unsigned int num=0;
@@ -322,7 +322,7 @@ static void aes_ctr128_encrypt(struct crypto_struct *cipher, void *in, void *out
#endif /* HAS_AES */
#ifdef HAS_DES
-static int des3_set_key(struct crypto_struct *cipher, void *key,void *IV) {
+static int des3_set_key(struct ssh_cipher_struct *cipher, void *key,void *IV) {
if (cipher->key == NULL) {
if (alloc_key(cipher) < 0) {
return -1;
@@ -339,7 +339,7 @@ static int des3_set_key(struct crypto_struct *cipher, void *key,void *IV) {
return 0;
}
-static void des3_encrypt(struct crypto_struct *cipher, void *in,
+static void des3_encrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
DES_ede3_cbc_encrypt(in, out, len, cipher->key,
(void*)((uint8_t*)cipher->key + sizeof(DES_key_schedule)),
@@ -347,7 +347,7 @@ static void des3_encrypt(struct crypto_struct *cipher, void *in,
cipher->IV, 1);
}
-static void des3_decrypt(struct crypto_struct *cipher, void *in,
+static void des3_decrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
DES_ede3_cbc_encrypt(in, out, len, cipher->key,
(void*)((uint8_t*)cipher->key + sizeof(DES_key_schedule)),
@@ -355,7 +355,7 @@ static void des3_decrypt(struct crypto_struct *cipher, void *in,
cipher->IV, 0);
}
-static void des3_1_encrypt(struct crypto_struct *cipher, void *in,
+static void des3_1_encrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
#ifdef DEBUG_CRYPTO
ssh_print_hexa("Encrypt IV before", cipher->IV, 24);
@@ -370,7 +370,7 @@ static void des3_1_encrypt(struct crypto_struct *cipher, void *in,
#endif
}
-static void des3_1_decrypt(struct crypto_struct *cipher, void *in,
+static void des3_1_decrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
#ifdef DEBUG_CRYPTO
ssh_print_hexa("Decrypt IV before", cipher->IV, 24);
@@ -392,10 +392,10 @@ static void des3_1_decrypt(struct crypto_struct *cipher, void *in,
/*
* The table of supported ciphers
*
- * WARNING: If you modify crypto_struct, you must make sure the order is
+ * WARNING: If you modify ssh_cipher_struct, you must make sure the order is
* correct!
*/
-static struct crypto_struct ssh_ciphertab[] = {
+static struct ssh_cipher_struct ssh_ciphertab[] = {
#ifdef HAS_BLOWFISH
{
"blowfish-cbc",
@@ -527,7 +527,7 @@ static struct crypto_struct ssh_ciphertab[] = {
};
-struct crypto_struct *ssh_get_ciphertab(void)
+struct ssh_cipher_struct *ssh_get_ciphertab(void)
{
return ssh_ciphertab;
}
diff --git a/src/libgcrypt.c b/src/libgcrypt.c
index b31ac709..70ce828d 100644
--- a/src/libgcrypt.c
+++ b/src/libgcrypt.c
@@ -36,7 +36,7 @@ struct ssh_mac_ctx_struct {
gcry_md_hd_t ctx;
};
-static int alloc_key(struct crypto_struct *cipher) {
+static int alloc_key(struct ssh_cipher_struct *cipher) {
cipher->key = malloc(cipher->keylen);
if (cipher->key == NULL) {
return -1;
@@ -166,7 +166,7 @@ void hmac_final(HMACCTX c, unsigned char *hashmacbuf, unsigned int *len) {
}
/* the wrapper functions for blowfish */
-static int blowfish_set_key(struct crypto_struct *cipher, void *key, void *IV){
+static int blowfish_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV){
if (cipher->key == NULL) {
if (alloc_key(cipher) < 0) {
return -1;
@@ -190,17 +190,17 @@ static int blowfish_set_key(struct crypto_struct *cipher, void *key, void *IV){
return 0;
}
-static void blowfish_encrypt(struct crypto_struct *cipher, void *in,
+static void blowfish_encrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
gcry_cipher_encrypt(cipher->key[0], out, len, in, len);
}
-static void blowfish_decrypt(struct crypto_struct *cipher, void *in,
+static void blowfish_decrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
gcry_cipher_decrypt(cipher->key[0], out, len, in, len);
}
-static int aes_set_key(struct crypto_struct *cipher, void *key, void *IV) {
+static int aes_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) {
int mode=GCRY_CIPHER_MODE_CBC;
if (cipher->key == NULL) {
if (alloc_key(cipher) < 0) {
@@ -252,17 +252,17 @@ static int aes_set_key(struct crypto_struct *cipher, void *key, void *IV) {
return 0;
}
-static void aes_encrypt(struct crypto_struct *cipher, void *in, void *out,
+static void aes_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
unsigned long len) {
gcry_cipher_encrypt(cipher->key[0], out, len, in, len);
}
-static void aes_decrypt(struct crypto_struct *cipher, void *in, void *out,
+static void aes_decrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
unsigned long len) {
gcry_cipher_decrypt(cipher->key[0], out, len, in, len);
}
-static int des3_set_key(struct crypto_struct *cipher, void *key, void *IV) {
+static int des3_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) {
if (cipher->key == NULL) {
if (alloc_key(cipher) < 0) {
return -1;
@@ -285,17 +285,17 @@ static int des3_set_key(struct crypto_struct *cipher, void *key, void *IV) {
return 0;
}
-static void des3_encrypt(struct crypto_struct *cipher, void *in,
+static void des3_encrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
gcry_cipher_encrypt(cipher->key[0], out, len, in, len);
}
-static void des3_decrypt(struct crypto_struct *cipher, void *in,
+static void des3_decrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
gcry_cipher_decrypt(cipher->key[0], out, len, in, len);
}
-static int des3_1_set_key(struct crypto_struct *cipher, void *key, void *IV) {
+static int des3_1_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) {
if (cipher->key == NULL) {
if (alloc_key(cipher) < 0) {
return -1;
@@ -346,14 +346,14 @@ static int des3_1_set_key(struct crypto_struct *cipher, void *key, void *IV) {
return 0;
}
-static void des3_1_encrypt(struct crypto_struct *cipher, void *in,
+static void des3_1_encrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
gcry_cipher_encrypt(cipher->key[0], out, len, in, len);
gcry_cipher_decrypt(cipher->key[1], in, len, out, len);
gcry_cipher_encrypt(cipher->key[2], out, len, in, len);
}
-static void des3_1_decrypt(struct crypto_struct *cipher, void *in,
+static void des3_1_decrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
gcry_cipher_decrypt(cipher->key[2], out, len, in, len);
gcry_cipher_encrypt(cipher->key[1], in, len, out, len);
@@ -361,7 +361,7 @@ static void des3_1_decrypt(struct crypto_struct *cipher, void *in,
}
/* the table of supported ciphers */
-static struct crypto_struct ssh_ciphertab[] = {
+static struct ssh_cipher_struct ssh_ciphertab[] = {
{
.name = "blowfish-cbc",
.blocksize = 8,
@@ -474,7 +474,7 @@ static struct crypto_struct ssh_ciphertab[] = {
}
};
-struct crypto_struct *ssh_get_ciphertab(void)
+struct ssh_cipher_struct *ssh_get_ciphertab(void)
{
return ssh_ciphertab;
}
diff --git a/src/wrapper.c b/src/wrapper.c
index 7e52ef5d..3a917200 100644
--- a/src/wrapper.c
+++ b/src/wrapper.c
@@ -49,10 +49,10 @@
#include "libssh/pki.h"
/* it allocates a new cipher structure based on its offset into the global table */
-static struct crypto_struct *cipher_new(int offset) {
- struct crypto_struct *cipher = NULL;
+static struct ssh_cipher_struct *cipher_new(int offset) {
+ struct ssh_cipher_struct *cipher = NULL;
- cipher = malloc(sizeof(struct crypto_struct));
+ cipher = malloc(sizeof(struct ssh_cipher_struct));
if (cipher == NULL) {
return NULL;
}
@@ -63,7 +63,7 @@ static struct crypto_struct *cipher_new(int offset) {
return cipher;
}
-static void cipher_free(struct crypto_struct *cipher) {
+static void cipher_free(struct ssh_cipher_struct *cipher) {
#ifdef HAVE_LIBGCRYPT
unsigned int i;
#endif
@@ -164,7 +164,7 @@ static int crypt_set_algorithms2(ssh_session session){
const char *wanted;
int i = 0;
int rc = SSH_ERROR;
- struct crypto_struct *ssh_ciphertab=ssh_get_ciphertab();
+ struct ssh_cipher_struct *ssh_ciphertab=ssh_get_ciphertab();
enter_function();
/* we must scan the kex entries to find crypto algorithms and set their appropriate structure */
@@ -230,7 +230,7 @@ error:
static int crypt_set_algorithms1(ssh_session session) {
int i = 0;
- struct crypto_struct *ssh_ciphertab=ssh_get_ciphertab();
+ struct ssh_cipher_struct *ssh_ciphertab=ssh_get_ciphertab();
/* right now, we force 3des-cbc to be taken */
while (ssh_ciphertab[i].name && strcmp(ssh_ciphertab[i].name,
@@ -268,7 +268,7 @@ int crypt_set_algorithms_server(ssh_session session){
char *method = NULL;
int i = 0;
int rc = SSH_ERROR;
- struct crypto_struct *ssh_ciphertab=ssh_get_ciphertab();
+ struct ssh_cipher_struct *ssh_ciphertab=ssh_get_ciphertab();
if (session == NULL) {
return SSH_ERROR;