1616#include "nx_csbcpb.h"
1717#include "nx.h"
1818
19+ struct sha256_state_be {
20+ __be32 state [SHA256_DIGEST_SIZE / 4 ];
21+ u64 count ;
22+ u8 buf [SHA256_BLOCK_SIZE ];
23+ };
1924
2025static int nx_crypto_ctx_sha256_init (struct crypto_tfm * tfm )
2126{
@@ -36,7 +41,7 @@ static int nx_crypto_ctx_sha256_init(struct crypto_tfm *tfm)
3641}
3742
3843static int nx_sha256_init (struct shash_desc * desc ) {
39- struct sha256_state * sctx = shash_desc_ctx (desc );
44+ struct sha256_state_be * sctx = shash_desc_ctx (desc );
4045
4146 memset (sctx , 0 , sizeof * sctx );
4247
@@ -56,7 +61,7 @@ static int nx_sha256_init(struct shash_desc *desc) {
5661static int nx_sha256_update (struct shash_desc * desc , const u8 * data ,
5762 unsigned int len )
5863{
59- struct sha256_state * sctx = shash_desc_ctx (desc );
64+ struct sha256_state_be * sctx = shash_desc_ctx (desc );
6065 struct nx_crypto_ctx * nx_ctx = crypto_tfm_ctx (& desc -> tfm -> base );
6166 struct nx_csbcpb * csbcpb = (struct nx_csbcpb * )nx_ctx -> csbcpb ;
6267 struct nx_sg * out_sg ;
@@ -175,7 +180,7 @@ static int nx_sha256_update(struct shash_desc *desc, const u8 *data,
175180
176181static int nx_sha256_final (struct shash_desc * desc , u8 * out )
177182{
178- struct sha256_state * sctx = shash_desc_ctx (desc );
183+ struct sha256_state_be * sctx = shash_desc_ctx (desc );
179184 struct nx_crypto_ctx * nx_ctx = crypto_tfm_ctx (& desc -> tfm -> base );
180185 struct nx_csbcpb * csbcpb = (struct nx_csbcpb * )nx_ctx -> csbcpb ;
181186 struct nx_sg * in_sg , * out_sg ;
@@ -245,7 +250,7 @@ static int nx_sha256_final(struct shash_desc *desc, u8 *out)
245250
246251static int nx_sha256_export (struct shash_desc * desc , void * out )
247252{
248- struct sha256_state * sctx = shash_desc_ctx (desc );
253+ struct sha256_state_be * sctx = shash_desc_ctx (desc );
249254
250255 memcpy (out , sctx , sizeof (* sctx ));
251256
@@ -254,7 +259,7 @@ static int nx_sha256_export(struct shash_desc *desc, void *out)
254259
255260static int nx_sha256_import (struct shash_desc * desc , const void * in )
256261{
257- struct sha256_state * sctx = shash_desc_ctx (desc );
262+ struct sha256_state_be * sctx = shash_desc_ctx (desc );
258263
259264 memcpy (sctx , in , sizeof (* sctx ));
260265
@@ -268,8 +273,8 @@ struct shash_alg nx_shash_sha256_alg = {
268273 .final = nx_sha256_final ,
269274 .export = nx_sha256_export ,
270275 .import = nx_sha256_import ,
271- .descsize = sizeof (struct sha256_state ),
272- .statesize = sizeof (struct sha256_state ),
276+ .descsize = sizeof (struct sha256_state_be ),
277+ .statesize = sizeof (struct sha256_state_be ),
273278 .base = {
274279 .cra_name = "sha256" ,
275280 .cra_driver_name = "sha256-nx" ,
0 commit comments