Quellcode durchsuchen

Remove not needed option

master
Krzysztof Kwiatkowski vor 9 Jahren
Ursprung
Commit
16deb8a259
2 geänderte Dateien mit 15 neuen und 8 gelöschten Zeilen
  1. +14
    -7
      src/enc_modes.c
  2. +1
    -1
      src/enc_modes.h

+ 14
- 7
src/enc_modes.c Datei anzeigen

@@ -9,8 +9,7 @@
#include <openssl/err.h>

static Result_t crypt( CryptoAttribs_t* attribs,
const Key_t* const key,
CryptoOperation operation )
const Key_t* const key)
{
assert(key != NULL);
assert(attribs != NULL);
@@ -31,7 +30,7 @@ static Result_t crypt( CryptoAttribs_t* attribs,

OP_CHECK(
EVP_CipherInit_ex( &ctx, EVP_aes_128_ecb(), NULL, key->key, NULL,
(operation == kEncrypt ? 1 : 0)) );
(attribs->operation == kEncrypt ? 1 : 0)) );
OP_CHECK( EVP_CIPHER_CTX_iv_length(&ctx) == 0);
EVP_CIPHER_CTX_set_padding(&ctx, 0);
OP_CHECK( EVP_CipherUpdate(&ctx, &out[ret], &ret, attribs->input, attribs->input_len) );
@@ -83,7 +82,8 @@ Result_t cbc_decrypt(
ecb_attribs.input_len = key->len;

// 1. Decrypt
if( crypt(&ecb_attribs, key, kDecrypt) != Result_OK )
ecb_attribs.operation = kDecrypt;
if( crypt(&ecb_attribs, key) != Result_OK )
return Result_Error;

// 2. Xor IV
@@ -145,7 +145,8 @@ Result_t cbc_encrypt(
ecb_attribs.input_len = bs;

// 2. Encrypt
if( crypt(&ecb_attribs, key, kEncrypt) != Result_OK )
ecb_attribs.operation = kEncrypt;
if( crypt(&ecb_attribs, key) != Result_OK )
return Result_Error;

// Encrypted block is my new IV
@@ -162,7 +163,13 @@ Result_t cbc_encrypt(
}

Result_t ecb_encrypt( CryptoAttribs_t* attribs, const Key_t* const key )
{ return crypt(attribs, key, kEncrypt); }
{
attribs->operation = kEncrypt;
return crypt(attribs, key);
}

Result_t ecb_decrypt( CryptoAttribs_t* attribs, const Key_t* const key )
{ return crypt(attribs, key, kDecrypt); }
{
attribs->operation = kDecrypt;
return crypt(attribs, key);
}

+ 1
- 1
src/enc_modes.h Datei anzeigen

@@ -3,7 +3,7 @@

#include "common.h"

Result_t crypt( CryptoAttribs_t* attribs, const Key_t* const key, CryptoOperation operation );
Result_t crypt( CryptoAttribs_t* attribs, const Key_t* const key );

Result_t cbc_encrypt( CryptoAttribs_t* attribs, const Key_t* const key );
Result_t cbc_decrypt( CryptoAttribs_t* attribs, const Key_t* const key );


Laden…
Abbrechen
Speichern