crypto: add crypto v2 SHA512 support
Change-Id: Idee2ada3d5da6aef2a170509da2efa6b1f6e4a9d Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com>
This commit is contained in:
parent
3320fa9361
commit
e7846385ca
|
|
@ -17,6 +17,8 @@ u32 crypto_algo_nbits(u32 algo)
|
|||
return 160;
|
||||
case CRYPTO_SHA256:
|
||||
return 256;
|
||||
case CRYPTO_SHA512:
|
||||
return 512;
|
||||
case CRYPTO_RSA512:
|
||||
return 512;
|
||||
case CRYPTO_RSA1024:
|
||||
|
|
|
|||
|
|
@ -64,6 +64,17 @@ static const u8 null_hash_sha256_value[] = {
|
|||
0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55
|
||||
};
|
||||
|
||||
static const u8 null_hash_sha512_value[] = {
|
||||
0xcf, 0x83, 0xe1, 0x35, 0x7e, 0xef, 0xb8, 0xbd,
|
||||
0xf1, 0x54, 0x28, 0x50, 0xd6, 0x6d, 0x80, 0x07,
|
||||
0xd6, 0x20, 0xe4, 0x05, 0x0b, 0x57, 0x15, 0xdc,
|
||||
0x83, 0xf4, 0xa9, 0x21, 0xd3, 0x6c, 0xe9, 0xce,
|
||||
0x47, 0xd0, 0xd1, 0x3c, 0x5d, 0x85, 0xf2, 0xb0,
|
||||
0xff, 0x83, 0x18, 0xd2, 0x87, 0x7e, 0xec, 0x2f,
|
||||
0x63, 0xb9, 0x31, 0xbd, 0x47, 0x41, 0x7a, 0x81,
|
||||
0xa5, 0x38, 0x32, 0x7a, 0xf9, 0x27, 0xda, 0x3e
|
||||
};
|
||||
|
||||
fdt_addr_t crypto_base;
|
||||
|
||||
static void word2byte(u32 word, u8 *ch, u32 endian)
|
||||
|
|
@ -166,6 +177,12 @@ int rk_hash_init(void *hw_ctx, u32 algo)
|
|||
tmp_ctx->digest_size = 32;
|
||||
tmp_ctx->null_hash = null_hash_sha256_value;
|
||||
break;
|
||||
case CRYPTO_SHA512:
|
||||
reg_ctrl |= CRYPTO_MODE_SHA512;
|
||||
tmp_ctx->digest_size = 64;
|
||||
tmp_ctx->null_hash = null_hash_sha512_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
goto exit;
|
||||
|
|
@ -426,6 +443,7 @@ static u32 rockchip_crypto_capability(struct udevice *dev)
|
|||
return CRYPTO_MD5 |
|
||||
CRYPTO_SHA1 |
|
||||
CRYPTO_SHA256 |
|
||||
CRYPTO_SHA512 |
|
||||
CRYPTO_RSA512 |
|
||||
CRYPTO_RSA1024 |
|
||||
CRYPTO_RSA2048 |
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
#define CRYPTO_MD5 BIT(0)
|
||||
#define CRYPTO_SHA1 BIT(1)
|
||||
#define CRYPTO_SHA256 BIT(2)
|
||||
#define CRYPTO_RSA512 BIT(3)
|
||||
#define CRYPTO_RSA1024 BIT(4)
|
||||
#define CRYPTO_RSA2048 BIT(5)
|
||||
#define CRYPTO_RSA3072 BIT(6)
|
||||
#define CRYPTO_RSA4096 BIT(7)
|
||||
#define CRYPTO_SHA512 BIT(3)
|
||||
|
||||
#define CRYPTO_RSA512 BIT(10)
|
||||
#define CRYPTO_RSA1024 BIT(11)
|
||||
#define CRYPTO_RSA2048 BIT(12)
|
||||
#define CRYPTO_RSA3072 BIT(13)
|
||||
#define CRYPTO_RSA4096 BIT(14)
|
||||
|
||||
#define BYTE2WORD(bytes) ((bytes) / 4)
|
||||
#define BITS2BYTE(nbits) ((nbits) / 8)
|
||||
|
|
|
|||
Loading…
Reference in New Issue