Re-add |EVP_des_ede|, which is ECB.
(I couldn't find an authoritative source of test data, including in OpenSSL's source, so I used OpenSSL's implementation to produce the test ciphertext.) This benefits globalplatform. Change-Id: Ifb79e77afb7efed1c329126a1a459bbf7ce6ca00 Reviewed-on: https://boringssl-review.googlesource.com/5725 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
8c413a2d94
commit
d82a7b24be
@ -71,6 +71,8 @@ static const EVP_CIPHER *GetCipher(const std::string &name) {
|
||||
return EVP_des_cbc();
|
||||
} else if (name == "DES-ECB") {
|
||||
return EVP_des_ecb();
|
||||
} else if (name == "DES-EDE") {
|
||||
return EVP_des_ede();
|
||||
} else if (name == "DES-EDE-CBC") {
|
||||
return EVP_des_ede_cbc();
|
||||
} else if (name == "DES-EDE3-CBC") {
|
||||
|
@ -179,3 +179,29 @@ static const EVP_CIPHER des_ede_cbc = {
|
||||
NULL /* cleanup */, NULL /* ctrl */, };
|
||||
|
||||
const EVP_CIPHER *EVP_des_ede_cbc(void) { return &des_ede_cbc; }
|
||||
|
||||
|
||||
static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out,
|
||||
const uint8_t *in, size_t in_len) {
|
||||
if (in_len < ctx->cipher->block_size) {
|
||||
return 1;
|
||||
}
|
||||
in_len -= ctx->cipher->block_size;
|
||||
|
||||
DES_EDE_KEY *dat = (DES_EDE_KEY *) ctx->cipher_data;
|
||||
size_t i;
|
||||
for (i = 0; i <= in_len; i += ctx->cipher->block_size) {
|
||||
DES_ecb3_encrypt((DES_cblock *) (in + i), (DES_cblock *) (out + i),
|
||||
&dat->ks.ks[0], &dat->ks.ks[1], &dat->ks.ks[2],
|
||||
ctx->encrypt);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_CIPHER des_ede_ecb = {
|
||||
NID_des_ede_cbc, 8 /* block_size */, 16 /* key_size */,
|
||||
0 /* iv_len */, sizeof(DES_EDE_KEY), EVP_CIPH_ECB_MODE,
|
||||
NULL /* app_data */, des_ede_init_key , des_ede_ecb_cipher,
|
||||
NULL /* cleanup */, NULL /* ctrl */, };
|
||||
|
||||
const EVP_CIPHER *EVP_des_ede(void) { return &des_ede_ecb; }
|
||||
|
@ -46,6 +46,14 @@ Plaintext = 37363534333231204E6F77206973207468652074696D6520666F722000000000
|
||||
Ciphertext = 7948C0DA4FE91CD815DCA96DBC9B60A857EB954F4DEB08EB98722642AE69257B
|
||||
|
||||
|
||||
# DES EDE tests
|
||||
Cipher = DES-EDE
|
||||
Key = 0123456789abcdeff1e0d3c2b5a49786
|
||||
IV = fedcba9876543210
|
||||
Plaintext = 37363534333231204E6F77206973207468652074696D6520666F722000000000
|
||||
Ciphertext = 22E889402E28422F8167AD279D90A566DA75B734E12C671FC2669AECB3E4FE8F
|
||||
|
||||
|
||||
# AES 128 ECB tests (from FIPS-197 test vectors, encrypt)
|
||||
Cipher = AES-128-ECB
|
||||
Key = 000102030405060708090A0B0C0D0E0F
|
||||
|
@ -76,6 +76,7 @@ OPENSSL_EXPORT const EVP_CIPHER *EVP_rc4(void);
|
||||
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_des_cbc(void);
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_des_ecb(void);
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_des_ede(void);
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_des_ede_cbc(void);
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_des_ede3_cbc(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user