@@ -50,6 +50,19 @@ static int __crypto_sha512_import(struct __sha512_ctx *ctx, const void *in)
5050 return 0 ;
5151}
5252
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+
5366/* SHA-384 */
5467
5568const u8 sha384_zero_message_hash [SHA384_DIGEST_SIZE ] = {
@@ -100,6 +113,16 @@ static int crypto_sha384_import(struct shash_desc *desc, const void *in)
100113 return __crypto_sha512_import (& SHA384_CTX (desc )-> ctx , in );
101114}
102115
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+
103126/* SHA-512 */
104127
105128const u8 sha512_zero_message_hash [SHA512_DIGEST_SIZE ] = {
@@ -152,6 +175,16 @@ static int crypto_sha512_import(struct shash_desc *desc, const void *in)
152175 return __crypto_sha512_import (& SHA512_CTX (desc )-> ctx , in );
153176}
154177
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+
155188/* HMAC-SHA384 */
156189
157190#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)
204237 return __crypto_sha512_import (& ctx -> ctx .sha_ctx , in );
205238}
206239
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+
207255/* HMAC-SHA512 */
208256
209257#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)
256304 return __crypto_sha512_import (& ctx -> ctx .sha_ctx , in );
257305}
258306
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+
259322/* Algorithm definitions */
260323
261324static struct shash_alg algs [] = {
@@ -272,6 +335,8 @@ static struct shash_alg algs[] = {
272335 .digest = crypto_sha384_digest ,
273336 .export = crypto_sha384_export ,
274337 .import = crypto_sha384_import ,
338+ .export_core = crypto_sha384_export_core ,
339+ .import_core = crypto_sha384_import_core ,
275340 .descsize = sizeof (struct sha384_ctx ),
276341 .statesize = SHA512_SHASH_STATE_SIZE ,
277342 },
@@ -288,6 +353,8 @@ static struct shash_alg algs[] = {
288353 .digest = crypto_sha512_digest ,
289354 .export = crypto_sha512_export ,
290355 .import = crypto_sha512_import ,
356+ .export_core = crypto_sha512_export_core ,
357+ .import_core = crypto_sha512_import_core ,
291358 .descsize = sizeof (struct sha512_ctx ),
292359 .statesize = SHA512_SHASH_STATE_SIZE ,
293360 },
@@ -306,6 +373,8 @@ static struct shash_alg algs[] = {
306373 .digest = crypto_hmac_sha384_digest ,
307374 .export = crypto_hmac_sha384_export ,
308375 .import = crypto_hmac_sha384_import ,
376+ .export_core = crypto_hmac_sha384_export_core ,
377+ .import_core = crypto_hmac_sha384_import_core ,
309378 .descsize = sizeof (struct hmac_sha384_ctx ),
310379 .statesize = SHA512_SHASH_STATE_SIZE ,
311380 },
@@ -324,6 +393,8 @@ static struct shash_alg algs[] = {
324393 .digest = crypto_hmac_sha512_digest ,
325394 .export = crypto_hmac_sha512_export ,
326395 .import = crypto_hmac_sha512_import ,
396+ .export_core = crypto_hmac_sha512_export_core ,
397+ .import_core = crypto_hmac_sha512_import_core ,
327398 .descsize = sizeof (struct hmac_sha512_ctx ),
328399 .statesize = SHA512_SHASH_STATE_SIZE ,
329400 },
0 commit comments