libcrypto: clean up EVP functions

This commit is contained in:
Aris Adamantiadis
2015-09-25 00:05:10 +02:00
parent 392e09e3de
commit e83b4e8129
3 changed files with 221 additions and 389 deletions

View File

@@ -59,6 +59,20 @@ enum ssh_key_exchange_e {
SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG
};
enum ssh_cipher_e {
SSH_CIPHER_NONE=0,
SSH_BLOWFISH_CBC,
SSH_3DES_CBC,
SSH_3DES_CBC_SSH1,
SSH_DES_CBC_SSH1,
SSH_AES128_CBC,
SSH_AES192_CBC,
SSH_AES256_CBC,
SSH_AES128_CTR,
SSH_AES192_CTR,
SSH_AES256_CTR
};
struct ssh_crypto_struct {
bignum e,f,x,k,y;
#ifdef HAVE_ECDH
@@ -104,12 +118,14 @@ struct ssh_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 */
enum ssh_cipher_e ciphertype;
#ifdef HAVE_LIBGCRYPT
size_t keylen; /* length of the key structure */
gcry_cipher_hd_t *key;
#elif defined HAVE_LIBCRYPTO
void *key; /* a key buffer allocated for the algo */
void *IV;
struct ssh_3des_key_schedule *des3_key;
const EVP_CIPHER *cipher;
EVP_CIPHER_CTX ctx;
#endif
unsigned int keysize; /* bytes of key used. != keylen */
/* sets the new key for immediate use */
@@ -119,6 +135,7 @@ struct ssh_cipher_struct {
unsigned long len);
void (*decrypt)(struct ssh_cipher_struct *cipher, void *in, void *out,
unsigned long len);
void (*cleanup)(struct ssh_cipher_struct *cipher);
};
/* vim: set ts=2 sw=2 et cindent: */