@@ -50,6 +50,19 @@ static int __crypto_sha512_import(struct __sha512_ctx *ctx, const void *in)
50
50
return 0 ;
51
51
}
52
52
53
+ static int __crypto_sha512_export_core (const struct __sha512_ctx * ctx ,
54
+ void * out )
55
+ {
56
+ memcpy (out , ctx , offsetof(struct __sha512_ctx , buf ));
57
+ return 0 ;
58
+ }
59
+
60
+ static int __crypto_sha512_import_core (struct __sha512_ctx * ctx , const void * in )
61
+ {
62
+ memcpy (ctx , in , offsetof(struct __sha512_ctx , buf ));
63
+ return 0 ;
64
+ }
65
+
53
66
/* SHA-384 */
54
67
55
68
const u8 sha384_zero_message_hash [SHA384_DIGEST_SIZE ] = {
@@ -100,6 +113,16 @@ static int crypto_sha384_import(struct shash_desc *desc, const void *in)
100
113
return __crypto_sha512_import (& SHA384_CTX (desc )-> ctx , in );
101
114
}
102
115
116
+ static int crypto_sha384_export_core (struct shash_desc * desc , void * out )
117
+ {
118
+ return __crypto_sha512_export_core (& SHA384_CTX (desc )-> ctx , out );
119
+ }
120
+
121
+ static int crypto_sha384_import_core (struct shash_desc * desc , const void * in )
122
+ {
123
+ return __crypto_sha512_import_core (& SHA384_CTX (desc )-> ctx , in );
124
+ }
125
+
103
126
/* SHA-512 */
104
127
105
128
const u8 sha512_zero_message_hash [SHA512_DIGEST_SIZE ] = {
@@ -152,6 +175,16 @@ static int crypto_sha512_import(struct shash_desc *desc, const void *in)
152
175
return __crypto_sha512_import (& SHA512_CTX (desc )-> ctx , in );
153
176
}
154
177
178
+ static int crypto_sha512_export_core (struct shash_desc * desc , void * out )
179
+ {
180
+ return __crypto_sha512_export_core (& SHA512_CTX (desc )-> ctx , out );
181
+ }
182
+
183
+ static int crypto_sha512_import_core (struct shash_desc * desc , const void * in )
184
+ {
185
+ return __crypto_sha512_import_core (& SHA512_CTX (desc )-> ctx , in );
186
+ }
187
+
155
188
/* HMAC-SHA384 */
156
189
157
190
#define HMAC_SHA384_KEY (tfm ) ((struct hmac_sha384_key *)crypto_shash_ctx(tfm))
@@ -204,6 +237,21 @@ static int crypto_hmac_sha384_import(struct shash_desc *desc, const void *in)
204
237
return __crypto_sha512_import (& ctx -> ctx .sha_ctx , in );
205
238
}
206
239
240
+ static int crypto_hmac_sha384_export_core (struct shash_desc * desc , void * out )
241
+ {
242
+ return __crypto_sha512_export_core (& HMAC_SHA384_CTX (desc )-> ctx .sha_ctx ,
243
+ out );
244
+ }
245
+
246
+ static int crypto_hmac_sha384_import_core (struct shash_desc * desc ,
247
+ const void * in )
248
+ {
249
+ struct hmac_sha384_ctx * ctx = HMAC_SHA384_CTX (desc );
250
+
251
+ ctx -> ctx .ostate = HMAC_SHA384_KEY (desc -> tfm )-> key .ostate ;
252
+ return __crypto_sha512_import_core (& ctx -> ctx .sha_ctx , in );
253
+ }
254
+
207
255
/* HMAC-SHA512 */
208
256
209
257
#define HMAC_SHA512_KEY (tfm ) ((struct hmac_sha512_key *)crypto_shash_ctx(tfm))
@@ -256,6 +304,21 @@ static int crypto_hmac_sha512_import(struct shash_desc *desc, const void *in)
256
304
return __crypto_sha512_import (& ctx -> ctx .sha_ctx , in );
257
305
}
258
306
307
+ static int crypto_hmac_sha512_export_core (struct shash_desc * desc , void * out )
308
+ {
309
+ return __crypto_sha512_export_core (& HMAC_SHA512_CTX (desc )-> ctx .sha_ctx ,
310
+ out );
311
+ }
312
+
313
+ static int crypto_hmac_sha512_import_core (struct shash_desc * desc ,
314
+ const void * in )
315
+ {
316
+ struct hmac_sha512_ctx * ctx = HMAC_SHA512_CTX (desc );
317
+
318
+ ctx -> ctx .ostate = HMAC_SHA512_KEY (desc -> tfm )-> key .ostate ;
319
+ return __crypto_sha512_import_core (& ctx -> ctx .sha_ctx , in );
320
+ }
321
+
259
322
/* Algorithm definitions */
260
323
261
324
static struct shash_alg algs [] = {
@@ -272,6 +335,8 @@ static struct shash_alg algs[] = {
272
335
.digest = crypto_sha384_digest ,
273
336
.export = crypto_sha384_export ,
274
337
.import = crypto_sha384_import ,
338
+ .export_core = crypto_sha384_export_core ,
339
+ .import_core = crypto_sha384_import_core ,
275
340
.descsize = sizeof (struct sha384_ctx ),
276
341
.statesize = SHA512_SHASH_STATE_SIZE ,
277
342
},
@@ -288,6 +353,8 @@ static struct shash_alg algs[] = {
288
353
.digest = crypto_sha512_digest ,
289
354
.export = crypto_sha512_export ,
290
355
.import = crypto_sha512_import ,
356
+ .export_core = crypto_sha512_export_core ,
357
+ .import_core = crypto_sha512_import_core ,
291
358
.descsize = sizeof (struct sha512_ctx ),
292
359
.statesize = SHA512_SHASH_STATE_SIZE ,
293
360
},
@@ -306,6 +373,8 @@ static struct shash_alg algs[] = {
306
373
.digest = crypto_hmac_sha384_digest ,
307
374
.export = crypto_hmac_sha384_export ,
308
375
.import = crypto_hmac_sha384_import ,
376
+ .export_core = crypto_hmac_sha384_export_core ,
377
+ .import_core = crypto_hmac_sha384_import_core ,
309
378
.descsize = sizeof (struct hmac_sha384_ctx ),
310
379
.statesize = SHA512_SHASH_STATE_SIZE ,
311
380
},
@@ -324,6 +393,8 @@ static struct shash_alg algs[] = {
324
393
.digest = crypto_hmac_sha512_digest ,
325
394
.export = crypto_hmac_sha512_export ,
326
395
.import = crypto_hmac_sha512_import ,
396
+ .export_core = crypto_hmac_sha512_export_core ,
397
+ .import_core = crypto_hmac_sha512_import_core ,
327
398
.descsize = sizeof (struct hmac_sha512_ctx ),
328
399
.statesize = SHA512_SHASH_STATE_SIZE ,
329
400
},
0 commit comments