diff options
author | tb <> | 2024-03-02 09:30:21 +0000 |
---|---|---|
committer | tb <> | 2024-03-02 09:30:21 +0000 |
commit | 27e901828ab79e35b7a6b736f5050679265ae63d (patch) | |
tree | 44c6059d07d7614a9e654590b63bf2cbc8e48bd6 | |
parent | c9bc42b7edc08f714c31d8ec1a974cc5b287ef4c (diff) | |
download | openbsd-27e901828ab79e35b7a6b736f5050679265ae63d.tar.gz openbsd-27e901828ab79e35b7a6b736f5050679265ae63d.tar.bz2 openbsd-27e901828ab79e35b7a6b736f5050679265ae63d.zip |
Remove CMAC_resume()
While it is a neat design detail of CMAC that you can resume it after
having finalized it, nothing uses this functionality and it adds some
gross things such as retaining intermediate secrets in the CMAC ctx.
Once this is gone, we can simplify the CMAC code a bit.
ok jsing
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 1 | ||||
-rw-r--r-- | src/lib/libcrypto/Symbols.namespace | 1 | ||||
-rw-r--r-- | src/lib/libcrypto/cmac/cmac.c | 17 | ||||
-rw-r--r-- | src/lib/libcrypto/cmac/cmac.h | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/hidden/openssl/cmac.h | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/man/CMAC_Init.3 | 26 |
6 files changed, 5 insertions, 46 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 5099a6f1f8..910a761787 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
@@ -478,7 +478,6 @@ CMAC_CTX_new | |||
478 | CMAC_Final | 478 | CMAC_Final |
479 | CMAC_Init | 479 | CMAC_Init |
480 | CMAC_Update | 480 | CMAC_Update |
481 | CMAC_resume | ||
482 | CMS_ContentInfo_free | 481 | CMS_ContentInfo_free |
483 | CMS_ContentInfo_it | 482 | CMS_ContentInfo_it |
484 | CMS_ContentInfo_new | 483 | CMS_ContentInfo_new |
diff --git a/src/lib/libcrypto/Symbols.namespace b/src/lib/libcrypto/Symbols.namespace index aff315a305..3b6be84b85 100644 --- a/src/lib/libcrypto/Symbols.namespace +++ b/src/lib/libcrypto/Symbols.namespace | |||
@@ -2433,7 +2433,6 @@ _libre_CMAC_CTX_copy | |||
2433 | _libre_CMAC_Init | 2433 | _libre_CMAC_Init |
2434 | _libre_CMAC_Update | 2434 | _libre_CMAC_Update |
2435 | _libre_CMAC_Final | 2435 | _libre_CMAC_Final |
2436 | _libre_CMAC_resume | ||
2437 | _libre_d2i_DSAparams_bio | 2436 | _libre_d2i_DSAparams_bio |
2438 | _libre_i2d_DSAparams_bio | 2437 | _libre_i2d_DSAparams_bio |
2439 | _libre_d2i_DSAparams_fp | 2438 | _libre_d2i_DSAparams_fp |
diff --git a/src/lib/libcrypto/cmac/cmac.c b/src/lib/libcrypto/cmac/cmac.c index 81d6ffc9b5..7ad3434836 100644 --- a/src/lib/libcrypto/cmac/cmac.c +++ b/src/lib/libcrypto/cmac/cmac.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cmac.c,v 1.22 2024/01/30 17:43:39 tb Exp $ */ | 1 | /* $OpenBSD: cmac.c,v 1.23 2024/03/02 09:30:21 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project. | 3 | * project. |
4 | */ | 4 | */ |
@@ -323,18 +323,3 @@ CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen) | |||
323 | return 1; | 323 | return 1; |
324 | } | 324 | } |
325 | LCRYPTO_ALIAS(CMAC_Final); | 325 | LCRYPTO_ALIAS(CMAC_Final); |
326 | |||
327 | int | ||
328 | CMAC_resume(CMAC_CTX *ctx) | ||
329 | { | ||
330 | if (ctx->nlast_block == -1) | ||
331 | return 0; | ||
332 | /* The buffer "tbl" containes the last fully encrypted block | ||
333 | * which is the last IV (or all zeroes if no last encrypted block). | ||
334 | * The last block has not been modified since CMAC_final(). | ||
335 | * So reinitialising using the last decrypted block will allow | ||
336 | * CMAC to continue after calling CMAC_Final(). | ||
337 | */ | ||
338 | return EVP_EncryptInit_ex(ctx->cipher_ctx, NULL, NULL, NULL, ctx->tbl); | ||
339 | } | ||
340 | LCRYPTO_ALIAS(CMAC_resume); | ||
diff --git a/src/lib/libcrypto/cmac/cmac.h b/src/lib/libcrypto/cmac/cmac.h index cb6d64b02f..f77dae12b3 100644 --- a/src/lib/libcrypto/cmac/cmac.h +++ b/src/lib/libcrypto/cmac/cmac.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cmac.h,v 1.3 2014/06/21 13:42:14 jsing Exp $ */ | 1 | /* $OpenBSD: cmac.h,v 1.4 2024/03/02 09:30:21 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project. | 3 | * project. |
4 | */ | 4 | */ |
@@ -74,7 +74,6 @@ int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, | |||
74 | const EVP_CIPHER *cipher, ENGINE *impl); | 74 | const EVP_CIPHER *cipher, ENGINE *impl); |
75 | int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); | 75 | int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); |
76 | int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); | 76 | int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); |
77 | int CMAC_resume(CMAC_CTX *ctx); | ||
78 | 77 | ||
79 | #ifdef __cplusplus | 78 | #ifdef __cplusplus |
80 | } | 79 | } |
diff --git a/src/lib/libcrypto/hidden/openssl/cmac.h b/src/lib/libcrypto/hidden/openssl/cmac.h index cefdb4f6e5..1e802aa887 100644 --- a/src/lib/libcrypto/hidden/openssl/cmac.h +++ b/src/lib/libcrypto/hidden/openssl/cmac.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cmac.h,v 1.1 2023/07/08 14:27:14 beck Exp $ */ | 1 | /* $OpenBSD: cmac.h,v 1.2 2024/03/02 09:30:21 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2023 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2023 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -33,6 +33,5 @@ LCRYPTO_USED(CMAC_CTX_copy); | |||
33 | LCRYPTO_USED(CMAC_Init); | 33 | LCRYPTO_USED(CMAC_Init); |
34 | LCRYPTO_USED(CMAC_Update); | 34 | LCRYPTO_USED(CMAC_Update); |
35 | LCRYPTO_USED(CMAC_Final); | 35 | LCRYPTO_USED(CMAC_Final); |
36 | LCRYPTO_USED(CMAC_resume); | ||
37 | 36 | ||
38 | #endif /* _LIBCRYPTO_CMAC_H */ | 37 | #endif /* _LIBCRYPTO_CMAC_H */ |
diff --git a/src/lib/libcrypto/man/CMAC_Init.3 b/src/lib/libcrypto/man/CMAC_Init.3 index 81cb8b8f0b..f4143cf451 100644 --- a/src/lib/libcrypto/man/CMAC_Init.3 +++ b/src/lib/libcrypto/man/CMAC_Init.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: CMAC_Init.3,v 1.5 2023/12/25 15:52:18 schwarze Exp $ | 1 | .\" $OpenBSD: CMAC_Init.3,v 1.6 2024/03/02 09:30:21 tb Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> |
4 | .\" | 4 | .\" |
@@ -14,7 +14,7 @@ | |||
14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | .\" | 16 | .\" |
17 | .Dd $Mdocdate: December 25 2023 $ | 17 | .Dd $Mdocdate: March 2 2024 $ |
18 | .Dt CMAC_INIT 3 | 18 | .Dt CMAC_INIT 3 |
19 | .Os | 19 | .Os |
20 | .Sh NAME | 20 | .Sh NAME |
@@ -22,7 +22,6 @@ | |||
22 | .Nm CMAC_Init , | 22 | .Nm CMAC_Init , |
23 | .Nm CMAC_Update , | 23 | .Nm CMAC_Update , |
24 | .Nm CMAC_Final , | 24 | .Nm CMAC_Final , |
25 | .Nm CMAC_resume , | ||
26 | .Nm CMAC_CTX_copy , | 25 | .Nm CMAC_CTX_copy , |
27 | .Nm CMAC_CTX_get0_cipher_ctx , | 26 | .Nm CMAC_CTX_get0_cipher_ctx , |
28 | .Nm CMAC_CTX_cleanup , | 27 | .Nm CMAC_CTX_cleanup , |
@@ -52,13 +51,6 @@ | |||
52 | .Fa "unsigned char *out_mac" | 51 | .Fa "unsigned char *out_mac" |
53 | .Fa "size_t *out_len" | 52 | .Fa "size_t *out_len" |
54 | .Fc | 53 | .Fc |
55 | .Ft int | ||
56 | .Fn CMAC_resume "CMAC_CTX *ctx" | ||
57 | .Ft int | ||
58 | .Fo CMAC_CTX_copy | ||
59 | .Fa "CMAC_CTX *out_ctx" | ||
60 | .Fa "CMAC_CTX *in_ctx" | ||
61 | .Fc | ||
62 | .Ft EVP_CIPHER_CTX * | 54 | .Ft EVP_CIPHER_CTX * |
63 | .Fn CMAC_CTX_get0_cipher_ctx "CMAC_CTX *ctx" | 55 | .Fn CMAC_CTX_get0_cipher_ctx "CMAC_CTX *ctx" |
64 | .Ft void | 56 | .Ft void |
@@ -183,19 +175,6 @@ resulting message authentication code to | |||
183 | .Fa out_mac . | 175 | .Fa out_mac . |
184 | The caller is responsible for providing a buffer of sufficient size. | 176 | The caller is responsible for providing a buffer of sufficient size. |
185 | .Pp | 177 | .Pp |
186 | Calling | ||
187 | .Fn CMAC_resume | ||
188 | after | ||
189 | .Fn CMAC_Final | ||
190 | allows the user to subsequently append additional data with | ||
191 | .Fn CMAC_Update . | ||
192 | Otherwise, unless | ||
193 | .Fn CMAC_Init | ||
194 | is called to start from scratch, | ||
195 | .Fn CMAC_Update | ||
196 | can no longer be used after | ||
197 | .Fn CMAC_Final . | ||
198 | .Pp | ||
199 | .Fn CMAC_CTX_copy | 178 | .Fn CMAC_CTX_copy |
200 | performs a deep copy of the already initialized | 179 | performs a deep copy of the already initialized |
201 | .Fa in_ctx | 180 | .Fa in_ctx |
@@ -235,7 +214,6 @@ It succeeds unless memory is exhausted. | |||
235 | .Fn CMAC_Init , | 214 | .Fn CMAC_Init , |
236 | .Fn CMAC_Update , | 215 | .Fn CMAC_Update , |
237 | .Fn CMAC_Final , | 216 | .Fn CMAC_Final , |
238 | .Fn CMAC_resume , | ||
239 | and | 217 | and |
240 | .Fn CMAC_CTX_copy | 218 | .Fn CMAC_CTX_copy |
241 | return 1 on success or 0 on failure. | 219 | return 1 on success or 0 on failure. |