diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-08-08 18:45:07 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-10-18 19:08:32 +0200 |
commit | caa9d9c1c5cc4347edca0c9a9868fdd105b5e779 (patch) | |
tree | 403787a018da9eced31d1f84b6493e59466dddc7 /utils/tomcrypt/src/headers/tomcrypt_pkcs.h | |
parent | 7603533f7fc9f7aec7c04a1258cf772247170e90 (diff) | |
download | rockbox-caa9d9c1c5cc4347edca0c9a9868fdd105b5e779.tar.gz rockbox-caa9d9c1c5cc4347edca0c9a9868fdd105b5e779.zip |
utils: Add (partial) libtomcrypt.
Add the parts of libtomcrypt that we're about to use.
Change-Id: I0adc1d7d1f4833e7bb3ed53b9a4d9a85977cfb8b
Diffstat (limited to 'utils/tomcrypt/src/headers/tomcrypt_pkcs.h')
-rw-r--r-- | utils/tomcrypt/src/headers/tomcrypt_pkcs.h | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/utils/tomcrypt/src/headers/tomcrypt_pkcs.h b/utils/tomcrypt/src/headers/tomcrypt_pkcs.h new file mode 100644 index 0000000000..b84028f122 --- /dev/null +++ b/utils/tomcrypt/src/headers/tomcrypt_pkcs.h | |||
@@ -0,0 +1,108 @@ | |||
1 | /* LibTomCrypt, modular cryptographic library -- Tom St Denis | ||
2 | * | ||
3 | * LibTomCrypt is a library that provides various cryptographic | ||
4 | * algorithms in a highly modular and flexible manner. | ||
5 | * | ||
6 | * The library is free for all purposes without any express | ||
7 | * guarantee it works. | ||
8 | */ | ||
9 | |||
10 | /* PKCS Header Info */ | ||
11 | |||
12 | /* ===> PKCS #1 -- RSA Cryptography <=== */ | ||
13 | #ifdef LTC_PKCS_1 | ||
14 | |||
15 | enum ltc_pkcs_1_v1_5_blocks | ||
16 | { | ||
17 | LTC_PKCS_1_EMSA = 1, /* Block type 1 (PKCS #1 v1.5 signature padding) */ | ||
18 | LTC_PKCS_1_EME = 2 /* Block type 2 (PKCS #1 v1.5 encryption padding) */ | ||
19 | }; | ||
20 | |||
21 | enum ltc_pkcs_1_paddings | ||
22 | { | ||
23 | LTC_PKCS_1_V1_5 = 1, /* PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */ | ||
24 | LTC_PKCS_1_OAEP = 2, /* PKCS #1 v2.0 encryption padding */ | ||
25 | LTC_PKCS_1_PSS = 3, /* PKCS #1 v2.1 signature padding */ | ||
26 | LTC_PKCS_1_V1_5_NA1 = 4 /* PKCS #1 v1.5 padding - No ASN.1 (\sa ltc_pkcs_1_v1_5_blocks) */ | ||
27 | }; | ||
28 | |||
29 | int pkcs_1_mgf1( int hash_idx, | ||
30 | const unsigned char *seed, unsigned long seedlen, | ||
31 | unsigned char *mask, unsigned long masklen); | ||
32 | |||
33 | int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out); | ||
34 | int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen); | ||
35 | |||
36 | /* *** v1.5 padding */ | ||
37 | int pkcs_1_v1_5_encode(const unsigned char *msg, | ||
38 | unsigned long msglen, | ||
39 | int block_type, | ||
40 | unsigned long modulus_bitlen, | ||
41 | prng_state *prng, | ||
42 | int prng_idx, | ||
43 | unsigned char *out, | ||
44 | unsigned long *outlen); | ||
45 | |||
46 | int pkcs_1_v1_5_decode(const unsigned char *msg, | ||
47 | unsigned long msglen, | ||
48 | int block_type, | ||
49 | unsigned long modulus_bitlen, | ||
50 | unsigned char *out, | ||
51 | unsigned long *outlen, | ||
52 | int *is_valid); | ||
53 | |||
54 | /* *** v2.1 padding */ | ||
55 | int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen, | ||
56 | const unsigned char *lparam, unsigned long lparamlen, | ||
57 | unsigned long modulus_bitlen, prng_state *prng, | ||
58 | int prng_idx, int hash_idx, | ||
59 | unsigned char *out, unsigned long *outlen); | ||
60 | |||
61 | int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen, | ||
62 | const unsigned char *lparam, unsigned long lparamlen, | ||
63 | unsigned long modulus_bitlen, int hash_idx, | ||
64 | unsigned char *out, unsigned long *outlen, | ||
65 | int *res); | ||
66 | |||
67 | int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen, | ||
68 | unsigned long saltlen, prng_state *prng, | ||
69 | int prng_idx, int hash_idx, | ||
70 | unsigned long modulus_bitlen, | ||
71 | unsigned char *out, unsigned long *outlen); | ||
72 | |||
73 | int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen, | ||
74 | const unsigned char *sig, unsigned long siglen, | ||
75 | unsigned long saltlen, int hash_idx, | ||
76 | unsigned long modulus_bitlen, int *res); | ||
77 | |||
78 | #endif /* LTC_PKCS_1 */ | ||
79 | |||
80 | /* ===> PKCS #5 -- Password Based Cryptography <=== */ | ||
81 | #ifdef LTC_PKCS_5 | ||
82 | |||
83 | /* Algorithm #1 (PBKDF1) */ | ||
84 | int pkcs_5_alg1(const unsigned char *password, unsigned long password_len, | ||
85 | const unsigned char *salt, | ||
86 | int iteration_count, int hash_idx, | ||
87 | unsigned char *out, unsigned long *outlen); | ||
88 | |||
89 | /* Algorithm #1 (PBKDF1) - OpenSSL-compatible variant for arbitrarily-long keys. | ||
90 | Compatible with EVP_BytesToKey() */ | ||
91 | int pkcs_5_alg1_openssl(const unsigned char *password, | ||
92 | unsigned long password_len, | ||
93 | const unsigned char *salt, | ||
94 | int iteration_count, int hash_idx, | ||
95 | unsigned char *out, unsigned long *outlen); | ||
96 | |||
97 | /* Algorithm #2 (PBKDF2) */ | ||
98 | int pkcs_5_alg2(const unsigned char *password, unsigned long password_len, | ||
99 | const unsigned char *salt, unsigned long salt_len, | ||
100 | int iteration_count, int hash_idx, | ||
101 | unsigned char *out, unsigned long *outlen); | ||
102 | |||
103 | int pkcs_5_test (void); | ||
104 | #endif /* LTC_PKCS_5 */ | ||
105 | |||
106 | /* ref: HEAD -> master, tag: v1.18.2 */ | ||
107 | /* git commit: 7e7eb695d581782f04b24dc444cbfde86af59853 */ | ||
108 | /* commit time: 2018-07-01 22:49:01 +0200 */ | ||