diff options
| author | tb <> | 2018-11-07 18:31:16 +0000 |
|---|---|---|
| committer | tb <> | 2018-11-07 18:31:16 +0000 |
| commit | 1ccfdc4633eea23918743a87973b287510d77c28 (patch) | |
| tree | 84ff1813d03af9a976c1c5a2b498a31b2165e8c2 /src | |
| parent | 82e426606d31d6e2709a9ffcc5b7635d463a7c49 (diff) | |
| download | openbsd-1ccfdc4633eea23918743a87973b287510d77c28.tar.gz openbsd-1ccfdc4633eea23918743a87973b287510d77c28.tar.bz2 openbsd-1ccfdc4633eea23918743a87973b287510d77c28.zip | |
Use memmove() instead of memcpy() to get rid of the need for
non-overlapping *in and *out buffers as we're already implementing
the "in place (un)wrapping" algorithms as given in RFC 3394. This
removes a gratuitous API difference to OpenSSLin these undocumented
functions. Found while working on wycheproof regress tests.
ok beck jsing
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/aes/aes_wrap.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libcrypto/aes/aes_wrap.c b/src/lib/libcrypto/aes/aes_wrap.c index b7e08ab75f..b30630fe47 100644 --- a/src/lib/libcrypto/aes/aes_wrap.c +++ b/src/lib/libcrypto/aes/aes_wrap.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: aes_wrap.c,v 1.11 2018/10/20 15:53:09 tb Exp $ */ | 1 | /* $OpenBSD: aes_wrap.c,v 1.12 2018/11/07 18:31:16 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 | */ |
| @@ -71,7 +71,7 @@ AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, | |||
| 71 | return -1; | 71 | return -1; |
| 72 | A = B; | 72 | A = B; |
| 73 | t = 1; | 73 | t = 1; |
| 74 | memcpy(out + 8, in, inlen); | 74 | memmove(out + 8, in, inlen); |
| 75 | if (!iv) | 75 | if (!iv) |
| 76 | iv = default_iv; | 76 | iv = default_iv; |
| 77 | 77 | ||
| @@ -108,7 +108,7 @@ AES_unwrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, | |||
| 108 | A = B; | 108 | A = B; |
| 109 | t = 6 * (inlen >> 3); | 109 | t = 6 * (inlen >> 3); |
| 110 | memcpy(A, in, 8); | 110 | memcpy(A, in, 8); |
| 111 | memcpy(out, in + 8, inlen); | 111 | memmove(out, in + 8, inlen); |
| 112 | for (j = 0; j < 6; j++) { | 112 | for (j = 0; j < 6; j++) { |
| 113 | R = out + inlen - 8; | 113 | R = out + inlen - 8; |
| 114 | for (i = 0; i < inlen; i += 8, t--, R -= 8) { | 114 | for (i = 0; i < inlen; i += 8, t--, R -= 8) { |
