| /optee_os/core/lib/libtomcrypt/ |
| H A D | sha256_accel.c | 68 static int sha256_compress_nblocks(hash_state *md, const unsigned char *buf, in sha256_compress_nblocks() argument 71 void *state = md->sha256.state; in sha256_compress_nblocks() 73 COMPILE_TIME_ASSERT(sizeof(md->sha256.state[0]) == sizeof(uint32_t)); in sha256_compress_nblocks() 79 static int sha256_compress(hash_state *md, const unsigned char *buf) in sha256_compress() argument 81 return sha256_compress_nblocks(md, buf, 1); in sha256_compress() 89 int sha256_init(hash_state * md) in sha256_init() argument 91 LTC_ARGCHK(md != NULL); in sha256_init() 93 md->sha256.curlen = 0; in sha256_init() 94 md->sha256.length = 0; in sha256_init() 95 md->sha256.state[0] = 0x6A09E667UL; in sha256_init() [all …]
|
| H A D | sha1_accel.c | 66 static int sha1_compress_nblocks(hash_state *md, const unsigned char *buf, in sha1_compress_nblocks() argument 69 void *state = md->sha1.state; in sha1_compress_nblocks() 71 COMPILE_TIME_ASSERT(sizeof(md->sha1.state[0]) == sizeof(uint32_t)); in sha1_compress_nblocks() 77 static int sha1_compress(hash_state *md, const unsigned char *buf) in sha1_compress() argument 79 return sha1_compress_nblocks(md, buf, 1); in sha1_compress() 96 int sha1_init(hash_state * md) in sha1_init() argument 98 LTC_ARGCHK(md != NULL); in sha1_init() 99 md->sha1.state[0] = 0x67452301UL; in sha1_init() 100 md->sha1.state[1] = 0xefcdab89UL; in sha1_init() 101 md->sha1.state[2] = 0x98badcfeUL; in sha1_init() [all …]
|
| H A D | sha3_accel.c | 77 int sha3_224_init(hash_state *md) in sha3_224_init() argument 79 LTC_ARGCHK(md != NULL); in sha3_224_init() 80 XMEMSET(&md->sha3, 0, sizeof(md->sha3)); in sha3_224_init() 81 md->sha3.capacity_words = 2 * 224 / (8 * sizeof(ulong64)); in sha3_224_init() 85 int sha3_256_init(hash_state *md) in sha3_256_init() argument 87 LTC_ARGCHK(md != NULL); in sha3_256_init() 88 XMEMSET(&md->sha3, 0, sizeof(md->sha3)); in sha3_256_init() 89 md->sha3.capacity_words = 2 * 256 / (8 * sizeof(ulong64)); in sha3_256_init() 93 int sha3_384_init(hash_state *md) in sha3_384_init() argument 95 LTC_ARGCHK(md != NULL); in sha3_384_init() [all …]
|
| H A D | sha512_accel.c | 36 static int sha512_compress_nblocks(hash_state *md, const unsigned char *buf, in sha512_compress_nblocks() argument 39 void *state = md->sha512.state; in sha512_compress_nblocks() 41 COMPILE_TIME_ASSERT(sizeof(md->sha512.state[0]) == sizeof(uint64_t)); in sha512_compress_nblocks() 48 static int sha512_compress(hash_state *md, const unsigned char *buf) in sha512_compress() argument 50 return sha512_compress_nblocks(md, buf, 1); in sha512_compress() 58 int sha512_init(hash_state * md) in sha512_init() argument 60 LTC_ARGCHK(md != NULL); in sha512_init() 61 md->sha512.curlen = 0; in sha512_init() 62 md->sha512.length = 0; in sha512_init() 63 md->sha512.state[0] = CONST64(0x6a09e667f3bcc908); in sha512_init() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/hashes/ |
| H A D | md2.c | 52 static void s_md2_update_chksum(hash_state *md) in s_md2_update_chksum() argument 56 L = md->md2.chksum[15]; in s_md2_update_chksum() 62 L = (md->md2.chksum[j] ^= PI_SUBST[(int)(md->md2.buf[j] ^ L)] & 255); in s_md2_update_chksum() 66 static void s_md2_compress(hash_state *md) in s_md2_compress() argument 73 md->md2.X[16+j] = md->md2.buf[j]; in s_md2_compress() 74 md->md2.X[32+j] = md->md2.X[j] ^ md->md2.X[16+j]; in s_md2_compress() 82 t = (md->md2.X[k] ^= PI_SUBST[(int)(t & 255)]); in s_md2_compress() 93 int md2_init(hash_state *md) in md2_init() argument 95 LTC_ARGCHK(md != NULL); in md2_init() 98 zeromem(md->md2.X, sizeof(md->md2.X)); in md2_init() [all …]
|
| H A D | sha3.c | 195 static LTC_INLINE int ss_done(hash_state *md, unsigned char *hash, ulong64 pad) in ss_done() argument 199 LTC_ARGCHK(md != NULL); in ss_done() 202 md->sha3.s[md->sha3.word_index] ^= (md->sha3.saved ^ (pad << (md->sha3.byte_index * 8))); in ss_done() 203 … md->sha3.s[SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words - 1] ^= CONST64(0x8000000000000000); in ss_done() 204 s_keccakf(md->sha3.s); in ss_done() 208 STORE64L(md->sha3.s[i], md->sha3.sb + i * 8); in ss_done() 211 XMEMCPY(hash, md->sha3.sb, md->sha3.capacity_words * 4); in ss_done() 217 int sha3_224_init(hash_state *md) in sha3_224_init() argument 219 LTC_ARGCHK(md != NULL); in sha3_224_init() 220 XMEMSET(&md->sha3, 0, sizeof(md->sha3)); in sha3_224_init() [all …]
|
| H A D | blake2b.c | 150 static void s_blake2b_set_lastnode(hash_state *md) { md->blake2b.f[1] = CONST64(0xffffffffffffffff)… in s_blake2b_set_lastnode() argument 153 static int s_blake2b_is_lastblock(const hash_state *md) { return md->blake2b.f[0] != 0; } in s_blake2b_is_lastblock() argument 155 static void s_blake2b_set_lastblock(hash_state *md) in s_blake2b_set_lastblock() argument 157 if (md->blake2b.last_node) { in s_blake2b_set_lastblock() 158 s_blake2b_set_lastnode(md); in s_blake2b_set_lastblock() 160 md->blake2b.f[0] = CONST64(0xffffffffffffffff); in s_blake2b_set_lastblock() 163 static void s_blake2b_increment_counter(hash_state *md, ulong64 inc) in s_blake2b_increment_counter() argument 165 md->blake2b.t[0] += inc; in s_blake2b_increment_counter() 166 if (md->blake2b.t[0] < inc) md->blake2b.t[1]++; in s_blake2b_increment_counter() 169 static void s_blake2b_init0(hash_state *md) in s_blake2b_init0() argument [all …]
|
| H A D | blake2s.c | 142 static void s_blake2s_set_lastnode(hash_state *md) { md->blake2s.f[1] = 0xffffffffUL; } in s_blake2s_set_lastnode() argument 145 static int s_blake2s_is_lastblock(const hash_state *md) { return md->blake2s.f[0] != 0; } in s_blake2s_is_lastblock() argument 147 static void s_blake2s_set_lastblock(hash_state *md) in s_blake2s_set_lastblock() argument 149 if (md->blake2s.last_node) { in s_blake2s_set_lastblock() 150 s_blake2s_set_lastnode(md); in s_blake2s_set_lastblock() 152 md->blake2s.f[0] = 0xffffffffUL; in s_blake2s_set_lastblock() 155 static void s_blake2s_increment_counter(hash_state *md, const ulong32 inc) in s_blake2s_increment_counter() argument 157 md->blake2s.t[0] += inc; in s_blake2s_increment_counter() 158 if (md->blake2s.t[0] < inc) md->blake2s.t[1]++; in s_blake2s_increment_counter() 161 static int s_blake2s_init0(hash_state *md) in s_blake2s_init0() argument [all …]
|
| H A D | sha1.c | 37 static int ss_sha1_compress(hash_state *md, const unsigned char *buf) in ss_sha1_compress() argument 39 static int s_sha1_compress(hash_state *md, const unsigned char *buf) in ss_sha1_compress() 53 a = md->sha1.state[0]; in ss_sha1_compress() 54 b = md->sha1.state[1]; in ss_sha1_compress() 55 c = md->sha1.state[2]; in ss_sha1_compress() 56 d = md->sha1.state[3]; in ss_sha1_compress() 57 e = md->sha1.state[4]; in ss_sha1_compress() 133 md->sha1.state[0] = md->sha1.state[0] + a; in ss_sha1_compress() 134 md->sha1.state[1] = md->sha1.state[1] + b; in ss_sha1_compress() 135 md->sha1.state[2] = md->sha1.state[2] + c; in ss_sha1_compress() [all …]
|
| H A D | md4.c | 68 static int ss_md4_compress(hash_state *md, const unsigned char *buf) in ss_md4_compress() argument 70 static int s_md4_compress(hash_state *md, const unsigned char *buf) in ss_md4_compress() 77 a = md->md4.state[0]; in ss_md4_compress() 78 b = md->md4.state[1]; in ss_md4_compress() 79 c = md->md4.state[2]; in ss_md4_compress() 80 d = md->md4.state[3]; in ss_md4_compress() 143 md->md4.state[0] = md->md4.state[0] + a; in ss_md4_compress() 144 md->md4.state[1] = md->md4.state[1] + b; in ss_md4_compress() 145 md->md4.state[2] = md->md4.state[2] + c; in ss_md4_compress() 146 md->md4.state[3] = md->md4.state[3] + d; in ss_md4_compress() [all …]
|
| H A D | md5.c | 93 static int ss_md5_compress(hash_state *md, const unsigned char *buf) in ss_md5_compress() argument 95 static int s_md5_compress(hash_state *md, const unsigned char *buf) in ss_md5_compress() 109 a = md->md5.state[0]; in ss_md5_compress() 110 b = md->md5.state[1]; in ss_md5_compress() 111 c = md->md5.state[2]; in ss_md5_compress() 112 d = md->md5.state[3]; in ss_md5_compress() 202 md->md5.state[0] = md->md5.state[0] + a; in ss_md5_compress() 203 md->md5.state[1] = md->md5.state[1] + b; in ss_md5_compress() 204 md->md5.state[2] = md->md5.state[2] + c; in ss_md5_compress() 205 md->md5.state[3] = md->md5.state[3] + d; in ss_md5_compress() [all …]
|
| H A D | rmd256.c | 70 static int ss_rmd256_compress(hash_state *md, const unsigned char *buf) in ss_rmd256_compress() argument 72 static int s_rmd256_compress(hash_state *md, const unsigned char *buf) in ss_rmd256_compress() 84 aa = md->rmd256.state[0]; in ss_rmd256_compress() 85 bb = md->rmd256.state[1]; in ss_rmd256_compress() 86 cc = md->rmd256.state[2]; in ss_rmd256_compress() 87 dd = md->rmd256.state[3]; in ss_rmd256_compress() 88 aaa = md->rmd256.state[4]; in ss_rmd256_compress() 89 bbb = md->rmd256.state[5]; in ss_rmd256_compress() 90 ccc = md->rmd256.state[6]; in ss_rmd256_compress() 91 ddd = md->rmd256.state[7]; in ss_rmd256_compress() [all …]
|
| H A D | tiger.c | 617 static int ss_tiger_compress(hash_state *md, const unsigned char *buf) in ss_tiger_compress() argument 619 static int s_tiger_compress(hash_state *md, const unsigned char *buf) in ss_tiger_compress() 629 a = md->tiger.state[0]; in ss_tiger_compress() 630 b = md->tiger.state[1]; in ss_tiger_compress() 631 c = md->tiger.state[2]; in ss_tiger_compress() 638 for (i = 3; i < md->tiger.passes; ++i) { in ss_tiger_compress() 645 md->tiger.state[0] = a ^ md->tiger.state[0]; in ss_tiger_compress() 646 md->tiger.state[1] = b - md->tiger.state[1]; in ss_tiger_compress() 647 md->tiger.state[2] = c + md->tiger.state[2]; in ss_tiger_compress() 653 static int s_tiger_compress(hash_state *md, const unsigned char *buf) in s_tiger_compress() argument [all …]
|
| H A D | rmd128.c | 76 static int ss_rmd128_compress(hash_state *md, const unsigned char *buf) in ss_rmd128_compress() argument 78 static int s_rmd128_compress(hash_state *md, const unsigned char *buf) in ss_rmd128_compress() 90 aa = aaa = md->rmd128.state[0]; in ss_rmd128_compress() 91 bb = bbb = md->rmd128.state[1]; in ss_rmd128_compress() 92 cc = ccc = md->rmd128.state[2]; in ss_rmd128_compress() 93 dd = ddd = md->rmd128.state[3]; in ss_rmd128_compress() 240 ddd += cc + md->rmd128.state[1]; /* final result for MDbuf[0] */ in ss_rmd128_compress() 241 md->rmd128.state[1] = md->rmd128.state[2] + dd + aaa; in ss_rmd128_compress() 242 md->rmd128.state[2] = md->rmd128.state[3] + aa + bbb; in ss_rmd128_compress() 243 md->rmd128.state[3] = md->rmd128.state[0] + bb + ccc; in ss_rmd128_compress() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/hashes/whirl/ |
| H A D | whirl.c | 50 static int ss_whirlpool_compress(hash_state *md, const unsigned char *buf) in ss_whirlpool_compress() argument 52 static int s_whirlpool_compress(hash_state *md, const unsigned char *buf) in ss_whirlpool_compress() 60 K[0][x] = md->whirlpool.state[x]; in ss_whirlpool_compress() 98 md->whirlpool.state[x] ^= T[0][x] ^ T[2][x]; in ss_whirlpool_compress() 106 static int s_whirlpool_compress(hash_state *md, const unsigned char *buf) in s_whirlpool_compress() argument 109 err = ss_whirlpool_compress(md, buf); in s_whirlpool_compress() 121 int whirlpool_init(hash_state * md) in whirlpool_init() argument 123 LTC_ARGCHK(md != NULL); in whirlpool_init() 124 zeromem(&md->whirlpool, sizeof(md->whirlpool)); in whirlpool_init() 143 int whirlpool_done(hash_state * md, unsigned char *out) in whirlpool_done() argument [all …]
|
| /optee_os/core/lib/libtomcrypt/src/headers/ |
| H A D | tomcrypt_hash.h | 245 int chc_init(hash_state * md); 246 int chc_process(hash_state * md, const unsigned char *in, unsigned long inlen); 247 int chc_done(hash_state * md, unsigned char *out); 253 int whirlpool_init(hash_state * md); 254 int whirlpool_process(hash_state * md, const unsigned char *in, unsigned long inlen); 255 int whirlpool_done(hash_state * md, unsigned char *out); 262 int sha3_512_init(hash_state * md); 263 int sha3_384_init(hash_state * md); 264 int sha3_256_init(hash_state * md); 265 int sha3_224_init(hash_state * md); [all …]
|
| /optee_os/core/lib/libtomcrypt/src/hashes/sha2/ |
| H A D | sha384.c | 35 int sha384_init(hash_state * md) in sha384_init() argument 37 LTC_ARGCHK(md != NULL); in sha384_init() 39 md->sha512.curlen = 0; in sha384_init() 40 md->sha512.length = 0; in sha384_init() 41 md->sha512.state[0] = CONST64(0xcbbb9d5dc1059ed8); in sha384_init() 42 md->sha512.state[1] = CONST64(0x629a292a367cd507); in sha384_init() 43 md->sha512.state[2] = CONST64(0x9159015a3070dd17); in sha384_init() 44 md->sha512.state[3] = CONST64(0x152fecd8f70e5939); in sha384_init() 45 md->sha512.state[4] = CONST64(0x67332667ffc00b31); in sha384_init() 46 md->sha512.state[5] = CONST64(0x8eb44a8768581511); in sha384_init() [all …]
|
| H A D | sha512_224.c | 35 int sha512_224_init(hash_state * md) in sha512_224_init() argument 37 LTC_ARGCHK(md != NULL); in sha512_224_init() 39 md->sha512.curlen = 0; in sha512_224_init() 40 md->sha512.length = 0; in sha512_224_init() 41 md->sha512.state[0] = CONST64(0x8C3D37C819544DA2); in sha512_224_init() 42 md->sha512.state[1] = CONST64(0x73E1996689DCD4D6); in sha512_224_init() 43 md->sha512.state[2] = CONST64(0x1DFAB7AE32FF9C82); in sha512_224_init() 44 md->sha512.state[3] = CONST64(0x679DD514582F9FCF); in sha512_224_init() 45 md->sha512.state[4] = CONST64(0x0F6D2B697BD44DA8); in sha512_224_init() 46 md->sha512.state[5] = CONST64(0x77E36F7304C48942); in sha512_224_init() [all …]
|
| H A D | sha512_256.c | 35 int sha512_256_init(hash_state * md) in sha512_256_init() argument 37 LTC_ARGCHK(md != NULL); in sha512_256_init() 39 md->sha512.curlen = 0; in sha512_256_init() 40 md->sha512.length = 0; in sha512_256_init() 41 md->sha512.state[0] = CONST64(0x22312194FC2BF72C); in sha512_256_init() 42 md->sha512.state[1] = CONST64(0x9F555FA3C84C64C2); in sha512_256_init() 43 md->sha512.state[2] = CONST64(0x2393B86B6F53B151); in sha512_256_init() 44 md->sha512.state[3] = CONST64(0x963877195940EABD); in sha512_256_init() 45 md->sha512.state[4] = CONST64(0x96283EE2A88EFFE3); in sha512_256_init() 46 md->sha512.state[5] = CONST64(0xBE5E1E2553863992); in sha512_256_init() [all …]
|
| H A D | sha224.c | 36 int sha224_init(hash_state * md) in sha224_init() argument 38 LTC_ARGCHK(md != NULL); in sha224_init() 40 md->sha256.curlen = 0; in sha224_init() 41 md->sha256.length = 0; in sha224_init() 42 md->sha256.state[0] = 0xc1059ed8UL; in sha224_init() 43 md->sha256.state[1] = 0x367cd507UL; in sha224_init() 44 md->sha256.state[2] = 0x3070dd17UL; in sha224_init() 45 md->sha256.state[3] = 0xf70e5939UL; in sha224_init() 46 md->sha256.state[4] = 0xffc00b31UL; in sha224_init() 47 md->sha256.state[5] = 0x68581511UL; in sha224_init() [all …]
|
| H A D | sha512.c | 86 static int ss_sha512_compress(hash_state * md, const unsigned char *buf) in ss_sha512_compress() argument 88 static int s_sha512_compress(hash_state * md, const unsigned char *buf) in ss_sha512_compress() 96 S[i] = md->sha512.state[i]; in ss_sha512_compress() 145 md->sha512.state[i] = md->sha512.state[i] + S[i]; in ss_sha512_compress() 153 static int s_sha512_compress(hash_state * md, const unsigned char *buf) in s_sha512_compress() argument 156 err = ss_sha512_compress(md, buf); in s_sha512_compress() 167 int sha512_init(hash_state * md) in sha512_init() argument 169 LTC_ARGCHK(md != NULL); in sha512_init() 170 md->sha512.curlen = 0; in sha512_init() 171 md->sha512.length = 0; in sha512_init() [all …]
|
| H A D | sha256.c | 61 static int ss_sha256_compress(hash_state * md, const unsigned char *buf) in ss_sha256_compress() argument 63 static int s_sha256_compress(hash_state * md, const unsigned char *buf) in ss_sha256_compress() 74 S[i] = md->sha256.state[i]; in ss_sha256_compress() 176 md->sha256.state[i] = md->sha256.state[i] + S[i]; in ss_sha256_compress() 182 static int s_sha256_compress(hash_state * md, const unsigned char *buf) in s_sha256_compress() argument 185 err = ss_sha256_compress(md, buf); in s_sha256_compress() 196 int sha256_init(hash_state * md) in sha256_init() argument 198 LTC_ARGCHK(md != NULL); in sha256_init() 200 md->sha256.curlen = 0; in sha256_init() 201 md->sha256.length = 0; in sha256_init() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/hashes/chc/ |
| H A D | chc.c | 79 int chc_init(hash_state *md) in chc_init() argument 85 LTC_ARGCHK(md != NULL); in chc_init() 108 cipher_descriptor[cipher_idx]->ecb_encrypt(buf, md->chc.state, key); in chc_init() 111 md->chc.length = 0; in chc_init() 112 md->chc.curlen = 0; in chc_init() 113 zeromem(md->chc.buf, sizeof(md->chc.buf)); in chc_init() 124 static int s_chc_compress(hash_state *md, const unsigned char *buf) in s_chc_compress() argument 133 …if ((err = cipher_descriptor[cipher_idx]->setup(md->chc.state, cipher_blocksize, 0, key)) != CRYPT… in s_chc_compress() 140 md->chc.state[x] ^= T[0][x] ^ T[1][x]; in s_chc_compress() 157 static int ss_chc_process(hash_state * md, const unsigned char *in, unsigned long inlen); [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/pkcs1/ |
| H A D | pkcs_1_mgf1.c | 28 hash_state *md; in pkcs_1_mgf1() local 43 md = XMALLOC(sizeof(hash_state)); in pkcs_1_mgf1() 45 if (md == NULL || buf == NULL) { in pkcs_1_mgf1() 46 if (md != NULL) { in pkcs_1_mgf1() 47 XFREE(md); in pkcs_1_mgf1() 64 if ((err = hash_descriptor[hash_idx]->init(md)) != CRYPT_OK) { in pkcs_1_mgf1() 67 if ((err = hash_descriptor[hash_idx]->process(md, seed, seedlen)) != CRYPT_OK) { in pkcs_1_mgf1() 70 if ((err = hash_descriptor[hash_idx]->process(md, buf, 4)) != CRYPT_OK) { in pkcs_1_mgf1() 73 if ((err = hash_descriptor[hash_idx]->done(md, buf)) != CRYPT_OK) { in pkcs_1_mgf1() 87 zeromem(md, sizeof(hash_state)); in pkcs_1_mgf1() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/hashes/helper/ |
| H A D | hash_memory.c | 22 hash_state *md; in hash_memory() local 38 md = XMALLOC(sizeof(hash_state)); in hash_memory() 39 if (md == NULL) { in hash_memory() 43 if ((err = hash_descriptor[hash]->init(md)) != CRYPT_OK) { in hash_memory() 46 if ((err = hash_descriptor[hash]->process(md, in, inlen)) != CRYPT_OK) { in hash_memory() 49 err = hash_descriptor[hash]->done(md, out); in hash_memory() 53 zeromem(md, sizeof(hash_state)); in hash_memory() 55 XFREE(md); in hash_memory()
|