diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2011-09-17 00:20:45 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2011-09-18 20:34:16 +0200 |
commit | af09313eac20e91e7e70336c3b8a45688a73d146 (patch) | |
tree | 0b731e2b25bb0307af0e47433a3f535451461b36 /src | |
parent | ac41a083efd64d94dfb15845c6c25ba5667ba8b8 (diff) | |
download | libssh-af09313eac20e91e7e70336c3b8a45688a73d146.tar.gz libssh-af09313eac20e91e7e70336c3b8a45688a73d146.tar.xz libssh-af09313eac20e91e7e70336c3b8a45688a73d146.zip |
crypto: rename crypto_struct -> ssh_cipher_struct
Diffstat (limited to 'src')
-rw-r--r-- | src/crypt.c | 4 | ||||
-rw-r--r-- | src/libcrypto.c | 34 | ||||
-rw-r--r-- | src/libgcrypt.c | 30 | ||||
-rw-r--r-- | src/wrapper.c | 14 |
4 files changed, 41 insertions, 41 deletions
diff --git a/src/crypt.c b/src/crypt.c index daeb70e..5acb126 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 0249103..747994e 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 b31ac70..70ce828 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 7e52ef5..3a91720 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; |