diff options
Diffstat (limited to 'src/cipher.c')
-rw-r--r-- | src/cipher.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/cipher.c b/src/cipher.c index 03449a0..a2e7f5e 100644 --- a/src/cipher.c +++ b/src/cipher.c @@ -210,7 +210,12 @@ int cipher_aesctr_init(cipher_t* c) if(!c->params_) return -2; -#ifdef USE_GCRYPT +#if defined(USE_SSL_CRYPTO) + // nothing here +#elif defined(USE_NETTLE) + // TODO: nettle + +#else // USE_GCRYPT is the default int algo; switch(c->key_length_) { case 128: algo = GCRY_CIPHER_AES128; break; @@ -239,7 +244,12 @@ void cipher_aesctr_close(cipher_t* c) return; if(c->params_) { -#ifdef USE_GCRYPT +#if defined(USE_SSL_CRYPTO) + // nothing here +#elif defined(USE_NETTLE) + // TODO: nettle + +#else // USE_GCRYPT is the default cipher_aesctr_param_t* params = c->params_; gcry_cipher_close(params->handle_); #endif @@ -285,12 +295,15 @@ int32_t cipher_aesctr_crypt(cipher_t* c, key_derivation_t* kd, key_derivation_di if(ret < 0) return ret; -#ifdef USE_SSL_CRYPTO +#if defined(USE_SSL_CRYPTO) ret = AES_set_encrypt_key(c->key_.buf_, c->key_length_, ¶ms->aes_key_); if(ret) { log_printf(ERROR, "failed to set cipher key (code: %d)", ret); return -1; } +#elif defined(USE_NETTLE) + // TODO: nettle + #else // USE_GCRYPT is the default gcry_error_t err = gcry_cipher_setkey(params->handle_, c->key_.buf_, c->key_.length_); if(err) { @@ -305,7 +318,7 @@ int32_t cipher_aesctr_crypt(cipher_t* c, key_derivation_t* kd, key_derivation_di return ret; } -#ifdef USE_SSL_CRYPTO +#if defined(USE_SSL_CRYPTO) if(C_AESCTR_CTR_LENGTH != AES_BLOCK_SIZE) { log_printf(ERROR, "failed to set cipher CTR: size doesn't fit"); return -1; @@ -313,6 +326,9 @@ int32_t cipher_aesctr_crypt(cipher_t* c, key_derivation_t* kd, key_derivation_di u_int32_t num = 0; memset(params->ecount_buf_, 0, AES_BLOCK_SIZE); AES_ctr128_encrypt(in, out, (ilen < olen) ? ilen : olen, ¶ms->aes_key_, params->ctr_.buf_, params->ecount_buf_, &num); +#elif defined(USE_NETTLE) + // TODO: nettle + #else // USE_GCRYPT is the default err = gcry_cipher_setctr(params->handle_, params->ctr_.buf_, C_AESCTR_CTR_LENGTH); if(err) { |