diff options
author | tb <> | 2019-03-17 18:07:41 +0000 |
---|---|---|
committer | tb <> | 2019-03-17 18:07:41 +0000 |
commit | fb0b540c39c782c9152081c2021f54363e04307c (patch) | |
tree | dd2e39bee98dd971a0881b58b8d9c80b4aed5bb3 /src | |
parent | 373c84ef2291a7b228066cf92fe5b23e39cd35aa (diff) | |
download | openbsd-fb0b540c39c782c9152081c2021f54363e04307c.tar.gz openbsd-fb0b540c39c782c9152081c2021f54363e04307c.tar.bz2 openbsd-fb0b540c39c782c9152081c2021f54363e04307c.zip |
Provide EVP_aes_{128,192,256}_wrap(). This is a compatible
implementation based on the one in OpenSSL 1.0.2r which is
still freely licensed.
The functions are undocumented in OpenSSL. To use them, one
needs to set the undocumented EVP_CIPHER_CTX_FLAG_WRAP_ALLOW
flag on the EVP_CIPHER_CTX.
resolves #505
ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/c_all.c | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/e_aes.c | 146 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/evp.h | 13 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/evp_enc.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/evp_err.c | 3 |
6 files changed, 174 insertions, 6 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 63e3ee45ac..9fdf723f87 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
@@ -1515,6 +1515,7 @@ EVP_aes_128_ctr | |||
1515 | EVP_aes_128_ecb | 1515 | EVP_aes_128_ecb |
1516 | EVP_aes_128_gcm | 1516 | EVP_aes_128_gcm |
1517 | EVP_aes_128_ofb | 1517 | EVP_aes_128_ofb |
1518 | EVP_aes_128_wrap | ||
1518 | EVP_aes_128_xts | 1519 | EVP_aes_128_xts |
1519 | EVP_aes_192_cbc | 1520 | EVP_aes_192_cbc |
1520 | EVP_aes_192_ccm | 1521 | EVP_aes_192_ccm |
@@ -1526,6 +1527,7 @@ EVP_aes_192_ctr | |||
1526 | EVP_aes_192_ecb | 1527 | EVP_aes_192_ecb |
1527 | EVP_aes_192_gcm | 1528 | EVP_aes_192_gcm |
1528 | EVP_aes_192_ofb | 1529 | EVP_aes_192_ofb |
1530 | EVP_aes_192_wrap | ||
1529 | EVP_aes_256_cbc | 1531 | EVP_aes_256_cbc |
1530 | EVP_aes_256_cbc_hmac_sha1 | 1532 | EVP_aes_256_cbc_hmac_sha1 |
1531 | EVP_aes_256_ccm | 1533 | EVP_aes_256_ccm |
@@ -1537,6 +1539,7 @@ EVP_aes_256_ctr | |||
1537 | EVP_aes_256_ecb | 1539 | EVP_aes_256_ecb |
1538 | EVP_aes_256_gcm | 1540 | EVP_aes_256_gcm |
1539 | EVP_aes_256_ofb | 1541 | EVP_aes_256_ofb |
1542 | EVP_aes_256_wrap | ||
1540 | EVP_aes_256_xts | 1543 | EVP_aes_256_xts |
1541 | EVP_bf_cbc | 1544 | EVP_bf_cbc |
1542 | EVP_bf_cfb | 1545 | EVP_bf_cfb |
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c index cce3640866..9e9d39d5ab 100644 --- a/src/lib/libcrypto/evp/c_all.c +++ b/src/lib/libcrypto/evp/c_all.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: c_all.c,v 1.25 2019/03/17 17:42:37 tb Exp $ */ | 1 | /* $OpenBSD: c_all.c,v 1.26 2019/03/17 18:07:41 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -159,6 +159,7 @@ OpenSSL_add_all_ciphers_internal(void) | |||
159 | EVP_add_cipher(EVP_aes_128_ofb()); | 159 | EVP_add_cipher(EVP_aes_128_ofb()); |
160 | EVP_add_cipher(EVP_aes_128_ctr()); | 160 | EVP_add_cipher(EVP_aes_128_ctr()); |
161 | EVP_add_cipher(EVP_aes_128_gcm()); | 161 | EVP_add_cipher(EVP_aes_128_gcm()); |
162 | EVP_add_cipher(EVP_aes_128_wrap()); | ||
162 | EVP_add_cipher(EVP_aes_128_xts()); | 163 | EVP_add_cipher(EVP_aes_128_xts()); |
163 | EVP_add_cipher_alias(SN_aes_128_cbc, "AES128"); | 164 | EVP_add_cipher_alias(SN_aes_128_cbc, "AES128"); |
164 | EVP_add_cipher_alias(SN_aes_128_cbc, "aes128"); | 165 | EVP_add_cipher_alias(SN_aes_128_cbc, "aes128"); |
@@ -171,6 +172,7 @@ OpenSSL_add_all_ciphers_internal(void) | |||
171 | EVP_add_cipher(EVP_aes_192_ofb()); | 172 | EVP_add_cipher(EVP_aes_192_ofb()); |
172 | EVP_add_cipher(EVP_aes_192_ctr()); | 173 | EVP_add_cipher(EVP_aes_192_ctr()); |
173 | EVP_add_cipher(EVP_aes_192_gcm()); | 174 | EVP_add_cipher(EVP_aes_192_gcm()); |
175 | EVP_add_cipher(EVP_aes_192_wrap()); | ||
174 | EVP_add_cipher_alias(SN_aes_192_cbc, "AES192"); | 176 | EVP_add_cipher_alias(SN_aes_192_cbc, "AES192"); |
175 | EVP_add_cipher_alias(SN_aes_192_cbc, "aes192"); | 177 | EVP_add_cipher_alias(SN_aes_192_cbc, "aes192"); |
176 | EVP_add_cipher(EVP_aes_256_ecb()); | 178 | EVP_add_cipher(EVP_aes_256_ecb()); |
@@ -182,6 +184,7 @@ OpenSSL_add_all_ciphers_internal(void) | |||
182 | EVP_add_cipher(EVP_aes_256_ofb()); | 184 | EVP_add_cipher(EVP_aes_256_ofb()); |
183 | EVP_add_cipher(EVP_aes_256_ctr()); | 185 | EVP_add_cipher(EVP_aes_256_ctr()); |
184 | EVP_add_cipher(EVP_aes_256_gcm()); | 186 | EVP_add_cipher(EVP_aes_256_gcm()); |
187 | EVP_add_cipher(EVP_aes_256_wrap()); | ||
185 | EVP_add_cipher(EVP_aes_256_xts()); | 188 | EVP_add_cipher(EVP_aes_256_xts()); |
186 | EVP_add_cipher_alias(SN_aes_256_cbc, "AES256"); | 189 | EVP_add_cipher_alias(SN_aes_256_cbc, "AES256"); |
187 | EVP_add_cipher_alias(SN_aes_256_cbc, "aes256"); | 190 | EVP_add_cipher_alias(SN_aes_256_cbc, "aes256"); |
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c index 7c713db026..6b455dc503 100644 --- a/src/lib/libcrypto/evp/e_aes.c +++ b/src/lib/libcrypto/evp/e_aes.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: e_aes.c,v 1.34 2017/05/02 03:59:44 deraadt Exp $ */ | 1 | /* $OpenBSD: e_aes.c,v 1.35 2019/03/17 18:07:41 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -49,6 +49,7 @@ | |||
49 | * | 49 | * |
50 | */ | 50 | */ |
51 | 51 | ||
52 | #include <limits.h> | ||
52 | #include <stdlib.h> | 53 | #include <stdlib.h> |
53 | #include <string.h> | 54 | #include <string.h> |
54 | 55 | ||
@@ -1549,4 +1550,147 @@ EVP_aead_aes_256_gcm(void) | |||
1549 | return &aead_aes_256_gcm; | 1550 | return &aead_aes_256_gcm; |
1550 | } | 1551 | } |
1551 | 1552 | ||
1553 | typedef struct { | ||
1554 | union { | ||
1555 | double align; | ||
1556 | AES_KEY ks; | ||
1557 | } ks; | ||
1558 | unsigned char *iv; | ||
1559 | } EVP_AES_WRAP_CTX; | ||
1560 | |||
1561 | static int | ||
1562 | aes_wrap_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
1563 | const unsigned char *iv, int enc) | ||
1564 | { | ||
1565 | EVP_AES_WRAP_CTX *wctx = (EVP_AES_WRAP_CTX *)ctx->cipher_data; | ||
1566 | |||
1567 | if (iv == NULL && key == NULL) | ||
1568 | return 1; | ||
1569 | |||
1570 | if (key != NULL) { | ||
1571 | if (ctx->encrypt) | ||
1572 | AES_set_encrypt_key(key, 8 * ctx->key_len, | ||
1573 | &wctx->ks.ks); | ||
1574 | else | ||
1575 | AES_set_decrypt_key(key, 8 * ctx->key_len, | ||
1576 | &wctx->ks.ks); | ||
1577 | |||
1578 | if (iv == NULL) | ||
1579 | wctx->iv = NULL; | ||
1580 | } | ||
1581 | |||
1582 | if (iv != NULL) { | ||
1583 | memcpy(ctx->iv, iv, EVP_CIPHER_CTX_iv_length(ctx)); | ||
1584 | wctx->iv = ctx->iv; | ||
1585 | } | ||
1586 | |||
1587 | return 1; | ||
1588 | } | ||
1589 | |||
1590 | static int | ||
1591 | aes_wrap_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
1592 | const unsigned char *in, size_t inlen) | ||
1593 | { | ||
1594 | EVP_AES_WRAP_CTX *wctx = ctx->cipher_data; | ||
1595 | int ret; | ||
1596 | |||
1597 | if (in == NULL) | ||
1598 | return 0; | ||
1599 | |||
1600 | if (inlen % 8 != 0) | ||
1601 | return -1; | ||
1602 | if (ctx->encrypt && inlen < 8) | ||
1603 | return -1; | ||
1604 | if (!ctx->encrypt && inlen < 16) | ||
1605 | return -1; | ||
1606 | if (inlen > INT_MAX) | ||
1607 | return -1; | ||
1608 | |||
1609 | if (out == NULL) { | ||
1610 | if (ctx->encrypt) | ||
1611 | return inlen + 8; | ||
1612 | else | ||
1613 | return inlen - 8; | ||
1614 | } | ||
1615 | |||
1616 | if (ctx->encrypt) | ||
1617 | ret = AES_wrap_key(&wctx->ks.ks, wctx->iv, out, in, | ||
1618 | (unsigned int)inlen); | ||
1619 | else | ||
1620 | ret = AES_unwrap_key(&wctx->ks.ks, wctx->iv, out, in, | ||
1621 | (unsigned int)inlen); | ||
1622 | |||
1623 | return ret != 0 ? ret : -1; | ||
1624 | } | ||
1625 | |||
1626 | #define WRAP_FLAGS \ | ||
1627 | ( EVP_CIPH_WRAP_MODE | EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER | \ | ||
1628 | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_FLAG_DEFAULT_ASN1 ) | ||
1629 | |||
1630 | static const EVP_CIPHER aes_128_wrap = { | ||
1631 | .nid = NID_id_aes128_wrap, | ||
1632 | .block_size = 8, | ||
1633 | .key_len = 16, | ||
1634 | .iv_len = 8, | ||
1635 | .flags = WRAP_FLAGS, | ||
1636 | .init = aes_wrap_init_key, | ||
1637 | .do_cipher = aes_wrap_cipher, | ||
1638 | .cleanup = NULL, | ||
1639 | .ctx_size = sizeof(EVP_AES_WRAP_CTX), | ||
1640 | .set_asn1_parameters = NULL, | ||
1641 | .get_asn1_parameters = NULL, | ||
1642 | .ctrl = NULL, | ||
1643 | .app_data = NULL, | ||
1644 | }; | ||
1645 | |||
1646 | const EVP_CIPHER * | ||
1647 | EVP_aes_128_wrap(void) | ||
1648 | { | ||
1649 | return &aes_128_wrap; | ||
1650 | } | ||
1651 | |||
1652 | static const EVP_CIPHER aes_192_wrap = { | ||
1653 | .nid = NID_id_aes192_wrap, | ||
1654 | .block_size = 8, | ||
1655 | .key_len = 24, | ||
1656 | .iv_len = 8, | ||
1657 | .flags = WRAP_FLAGS, | ||
1658 | .init = aes_wrap_init_key, | ||
1659 | .do_cipher = aes_wrap_cipher, | ||
1660 | .cleanup = NULL, | ||
1661 | .ctx_size = sizeof(EVP_AES_WRAP_CTX), | ||
1662 | .set_asn1_parameters = NULL, | ||
1663 | .get_asn1_parameters = NULL, | ||
1664 | .ctrl = NULL, | ||
1665 | .app_data = NULL, | ||
1666 | }; | ||
1667 | |||
1668 | const EVP_CIPHER * | ||
1669 | EVP_aes_192_wrap(void) | ||
1670 | { | ||
1671 | return &aes_192_wrap; | ||
1672 | } | ||
1673 | |||
1674 | static const EVP_CIPHER aes_256_wrap = { | ||
1675 | .nid = NID_id_aes256_wrap, | ||
1676 | .block_size = 8, | ||
1677 | .key_len = 32, | ||
1678 | .iv_len = 8, | ||
1679 | .flags = WRAP_FLAGS, | ||
1680 | .init = aes_wrap_init_key, | ||
1681 | .do_cipher = aes_wrap_cipher, | ||
1682 | .cleanup = NULL, | ||
1683 | .ctx_size = sizeof(EVP_AES_WRAP_CTX), | ||
1684 | .set_asn1_parameters = NULL, | ||
1685 | .get_asn1_parameters = NULL, | ||
1686 | .ctrl = NULL, | ||
1687 | .app_data = NULL, | ||
1688 | }; | ||
1689 | |||
1690 | const EVP_CIPHER * | ||
1691 | EVP_aes_256_wrap(void) | ||
1692 | { | ||
1693 | return &aes_256_wrap; | ||
1694 | } | ||
1695 | |||
1552 | #endif | 1696 | #endif |
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h index cd9b33c9b8..22876f9fe9 100644 --- a/src/lib/libcrypto/evp/evp.h +++ b/src/lib/libcrypto/evp/evp.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: evp.h,v 1.73 2019/03/17 17:42:37 tb Exp $ */ | 1 | /* $OpenBSD: evp.h,v 1.74 2019/03/17 18:07:41 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -325,6 +325,7 @@ struct evp_cipher_st { | |||
325 | #define EVP_CIPH_GCM_MODE 0x6 | 325 | #define EVP_CIPH_GCM_MODE 0x6 |
326 | #define EVP_CIPH_CCM_MODE 0x7 | 326 | #define EVP_CIPH_CCM_MODE 0x7 |
327 | #define EVP_CIPH_XTS_MODE 0x10001 | 327 | #define EVP_CIPH_XTS_MODE 0x10001 |
328 | #define EVP_CIPH_WRAP_MODE 0x10002 | ||
328 | #define EVP_CIPH_MODE 0xF0007 | 329 | #define EVP_CIPH_MODE 0xF0007 |
329 | /* Set if variable length cipher */ | 330 | /* Set if variable length cipher */ |
330 | #define EVP_CIPH_VARIABLE_LENGTH 0x8 | 331 | #define EVP_CIPH_VARIABLE_LENGTH 0x8 |
@@ -356,6 +357,12 @@ struct evp_cipher_st { | |||
356 | #define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000 | 357 | #define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000 |
357 | #define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000 | 358 | #define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000 |
358 | 359 | ||
360 | /* | ||
361 | * Cipher context flag to indicate that we can handle wrap mode: if allowed in | ||
362 | * older applications, it could overflow buffers. | ||
363 | */ | ||
364 | #define EVP_CIPHER_CTX_FLAG_WRAP_ALLOW 0x1 | ||
365 | |||
359 | /* ctrl() values */ | 366 | /* ctrl() values */ |
360 | 367 | ||
361 | #define EVP_CTRL_INIT 0x0 | 368 | #define EVP_CTRL_INIT 0x0 |
@@ -776,6 +783,7 @@ const EVP_CIPHER *EVP_aes_128_ofb(void); | |||
776 | const EVP_CIPHER *EVP_aes_128_ctr(void); | 783 | const EVP_CIPHER *EVP_aes_128_ctr(void); |
777 | const EVP_CIPHER *EVP_aes_128_ccm(void); | 784 | const EVP_CIPHER *EVP_aes_128_ccm(void); |
778 | const EVP_CIPHER *EVP_aes_128_gcm(void); | 785 | const EVP_CIPHER *EVP_aes_128_gcm(void); |
786 | const EVP_CIPHER *EVP_aes_128_wrap(void); | ||
779 | const EVP_CIPHER *EVP_aes_128_xts(void); | 787 | const EVP_CIPHER *EVP_aes_128_xts(void); |
780 | const EVP_CIPHER *EVP_aes_192_ecb(void); | 788 | const EVP_CIPHER *EVP_aes_192_ecb(void); |
781 | const EVP_CIPHER *EVP_aes_192_cbc(void); | 789 | const EVP_CIPHER *EVP_aes_192_cbc(void); |
@@ -787,6 +795,7 @@ const EVP_CIPHER *EVP_aes_192_ofb(void); | |||
787 | const EVP_CIPHER *EVP_aes_192_ctr(void); | 795 | const EVP_CIPHER *EVP_aes_192_ctr(void); |
788 | const EVP_CIPHER *EVP_aes_192_ccm(void); | 796 | const EVP_CIPHER *EVP_aes_192_ccm(void); |
789 | const EVP_CIPHER *EVP_aes_192_gcm(void); | 797 | const EVP_CIPHER *EVP_aes_192_gcm(void); |
798 | const EVP_CIPHER *EVP_aes_192_wrap(void); | ||
790 | const EVP_CIPHER *EVP_aes_256_ecb(void); | 799 | const EVP_CIPHER *EVP_aes_256_ecb(void); |
791 | const EVP_CIPHER *EVP_aes_256_cbc(void); | 800 | const EVP_CIPHER *EVP_aes_256_cbc(void); |
792 | const EVP_CIPHER *EVP_aes_256_cfb1(void); | 801 | const EVP_CIPHER *EVP_aes_256_cfb1(void); |
@@ -797,6 +806,7 @@ const EVP_CIPHER *EVP_aes_256_ofb(void); | |||
797 | const EVP_CIPHER *EVP_aes_256_ctr(void); | 806 | const EVP_CIPHER *EVP_aes_256_ctr(void); |
798 | const EVP_CIPHER *EVP_aes_256_ccm(void); | 807 | const EVP_CIPHER *EVP_aes_256_ccm(void); |
799 | const EVP_CIPHER *EVP_aes_256_gcm(void); | 808 | const EVP_CIPHER *EVP_aes_256_gcm(void); |
809 | const EVP_CIPHER *EVP_aes_256_wrap(void); | ||
800 | const EVP_CIPHER *EVP_aes_256_xts(void); | 810 | const EVP_CIPHER *EVP_aes_256_xts(void); |
801 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) | 811 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1) |
802 | const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void); | 812 | const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void); |
@@ -1523,6 +1533,7 @@ void ERR_load_EVP_strings(void); | |||
1523 | #define EVP_R_UNSUPPORTED_KEY_SIZE 108 | 1533 | #define EVP_R_UNSUPPORTED_KEY_SIZE 108 |
1524 | #define EVP_R_UNSUPPORTED_PRF 125 | 1534 | #define EVP_R_UNSUPPORTED_PRF 125 |
1525 | #define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 | 1535 | #define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 |
1536 | #define EVP_R_WRAP_MODE_NOT_ALLOWED 170 | ||
1526 | #define EVP_R_UNSUPPORTED_SALT_TYPE 126 | 1537 | #define EVP_R_UNSUPPORTED_SALT_TYPE 126 |
1527 | #define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 | 1538 | #define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 |
1528 | #define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 | 1539 | #define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 |
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c index db2deb6905..a229901956 100644 --- a/src/lib/libcrypto/evp/evp_enc.c +++ b/src/lib/libcrypto/evp/evp_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: evp_enc.c,v 1.39 2018/04/14 07:09:21 tb Exp $ */ | 1 | /* $OpenBSD: evp_enc.c,v 1.40 2019/03/17 18:07:41 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -153,7 +153,7 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | |||
153 | ctx->cipher_data = NULL; | 153 | ctx->cipher_data = NULL; |
154 | } | 154 | } |
155 | ctx->key_len = cipher->key_len; | 155 | ctx->key_len = cipher->key_len; |
156 | ctx->flags = 0; | 156 | ctx->flags &= EVP_CIPHER_CTX_FLAG_WRAP_ALLOW; |
157 | if (ctx->cipher->flags & EVP_CIPH_CTRL_INIT) { | 157 | if (ctx->cipher->flags & EVP_CIPH_CTRL_INIT) { |
158 | if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { | 158 | if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL)) { |
159 | EVPerror(EVP_R_INITIALIZATION_ERROR); | 159 | EVPerror(EVP_R_INITIALIZATION_ERROR); |
@@ -175,6 +175,12 @@ skip_to_init: | |||
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | if (!(ctx->flags & EVP_CIPHER_CTX_FLAG_WRAP_ALLOW) && | ||
179 | EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_WRAP_MODE) { | ||
180 | EVPerror(EVP_R_WRAP_MODE_NOT_ALLOWED); | ||
181 | return 0; | ||
182 | } | ||
183 | |||
178 | if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) { | 184 | if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) { |
179 | switch (EVP_CIPHER_CTX_mode(ctx)) { | 185 | switch (EVP_CIPHER_CTX_mode(ctx)) { |
180 | 186 | ||
diff --git a/src/lib/libcrypto/evp/evp_err.c b/src/lib/libcrypto/evp/evp_err.c index 1e1cc8350b..814637c739 100644 --- a/src/lib/libcrypto/evp/evp_err.c +++ b/src/lib/libcrypto/evp/evp_err.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: evp_err.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: evp_err.c,v 1.23 2019/03/17 18:07:41 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -147,6 +147,7 @@ static ERR_STRING_DATA EVP_str_reasons[] = { | |||
147 | {ERR_REASON(EVP_R_UNSUPPORTED_PRF) , "unsupported prf"}, | 147 | {ERR_REASON(EVP_R_UNSUPPORTED_PRF) , "unsupported prf"}, |
148 | {ERR_REASON(EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM), "unsupported private key algorithm"}, | 148 | {ERR_REASON(EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM), "unsupported private key algorithm"}, |
149 | {ERR_REASON(EVP_R_UNSUPPORTED_SALT_TYPE) , "unsupported salt type"}, | 149 | {ERR_REASON(EVP_R_UNSUPPORTED_SALT_TYPE) , "unsupported salt type"}, |
150 | {ERR_REASON(EVP_R_WRAP_MODE_NOT_ALLOWED), "wrap mode not allowed"}, | ||
150 | {ERR_REASON(EVP_R_WRONG_FINAL_BLOCK_LENGTH), "wrong final block length"}, | 151 | {ERR_REASON(EVP_R_WRONG_FINAL_BLOCK_LENGTH), "wrong final block length"}, |
151 | {ERR_REASON(EVP_R_WRONG_PUBLIC_KEY_TYPE) , "wrong public key type"}, | 152 | {ERR_REASON(EVP_R_WRONG_PUBLIC_KEY_TYPE) , "wrong public key type"}, |
152 | {0, NULL} | 153 | {0, NULL} |