diff options
Diffstat (limited to 'src/lib/libcrypto/gost/gost89_keywrap.c')
-rw-r--r-- | src/lib/libcrypto/gost/gost89_keywrap.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/lib/libcrypto/gost/gost89_keywrap.c b/src/lib/libcrypto/gost/gost89_keywrap.c index 8f641b6cef..fa7698d3f7 100644 --- a/src/lib/libcrypto/gost/gost89_keywrap.c +++ b/src/lib/libcrypto/gost/gost89_keywrap.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: gost89_keywrap.c,v 1.1 2014/11/09 19:17:13 miod Exp $ */ | 1 | /* $OpenBSD: gost89_keywrap.c,v 1.2 2014/11/09 19:27:29 miod Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
4 | * Copyright (c) 2005-2006 Cryptocom LTD | 4 | * Copyright (c) 2005-2006 Cryptocom LTD |
@@ -59,14 +59,15 @@ | |||
59 | 59 | ||
60 | #include "gost_locl.h" | 60 | #include "gost_locl.h" |
61 | 61 | ||
62 | static void key_diversify_crypto_pro(GOST2814789_KEY * ctx, const unsigned char *inputKey, | 62 | static void |
63 | const unsigned char *ukm, unsigned char *outputKey) | 63 | key_diversify_crypto_pro(GOST2814789_KEY *ctx, const unsigned char *inputKey, |
64 | const unsigned char *ukm, unsigned char *outputKey) | ||
64 | { | 65 | { |
65 | |||
66 | unsigned long k, s1, s2; | 66 | unsigned long k, s1, s2; |
67 | int i, mask; | 67 | int i, mask; |
68 | unsigned char S[8]; | 68 | unsigned char S[8]; |
69 | unsigned char *p; | 69 | unsigned char *p; |
70 | |||
70 | memcpy(outputKey, inputKey, 32); | 71 | memcpy(outputKey, inputKey, 32); |
71 | for (i = 0; i < 8; i++) { | 72 | for (i = 0; i < 8; i++) { |
72 | /* Make array of integers from key */ | 73 | /* Make array of integers from key */ |
@@ -86,13 +87,15 @@ static void key_diversify_crypto_pro(GOST2814789_KEY * ctx, const unsigned char | |||
86 | l2c (s2, p); | 87 | l2c (s2, p); |
87 | Gost2814789_set_key(ctx, outputKey, 256); | 88 | Gost2814789_set_key(ctx, outputKey, 256); |
88 | mask = 0; | 89 | mask = 0; |
89 | Gost2814789_cfb64_encrypt(outputKey, outputKey, 32, ctx, S, &mask, 1); | 90 | Gost2814789_cfb64_encrypt(outputKey, outputKey, 32, ctx, S, |
91 | &mask, 1); | ||
90 | } | 92 | } |
91 | } | 93 | } |
92 | 94 | ||
93 | int key_wrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, | 95 | int |
94 | const unsigned char *ukm, const unsigned char *sessionKey, | 96 | gost_key_wrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, |
95 | unsigned char *wrappedKey) | 97 | const unsigned char *ukm, const unsigned char *sessionKey, |
98 | unsigned char *wrappedKey) | ||
96 | { | 99 | { |
97 | GOST2814789_KEY ctx; | 100 | GOST2814789_KEY ctx; |
98 | unsigned char kek_ukm[32]; | 101 | unsigned char kek_ukm[32]; |
@@ -109,9 +112,9 @@ int key_wrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, | |||
109 | return 1; | 112 | return 1; |
110 | } | 113 | } |
111 | 114 | ||
112 | int key_unwrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, | 115 | int |
113 | const unsigned char *wrappedKey, | 116 | gost_key_unwrap_crypto_pro(int nid, const unsigned char *keyExchangeKey, |
114 | unsigned char *sessionKey) | 117 | const unsigned char *wrappedKey, unsigned char *sessionKey) |
115 | { | 118 | { |
116 | unsigned char kek_ukm[32], cek_mac[4]; | 119 | unsigned char kek_ukm[32], cek_mac[4]; |
117 | GOST2814789_KEY ctx; | 120 | GOST2814789_KEY ctx; |