Mercurial > dropbear
comparison pkcs_1_pss_encode.c @ 15:6362d3854bb4 libtomcrypt-orig
0.96 release of LibTomCrypt
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 15 Jun 2004 14:07:21 +0000 |
parents | 7faae8f46238 |
children | 5d99163f7e32 |
comparison
equal
deleted
inserted
replaced
3:7faae8f46238 | 15:6362d3854bb4 |
---|---|
13 /* PKCS #1 PSS Signature Padding -- Tom St Denis */ | 13 /* PKCS #1 PSS Signature Padding -- Tom St Denis */ |
14 | 14 |
15 #ifdef PKCS_1 | 15 #ifdef PKCS_1 |
16 | 16 |
17 int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen, | 17 int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen, |
18 unsigned long saltlen, int hash_idx, | 18 unsigned long saltlen, prng_state *prng, |
19 int prng_idx, prng_state *prng, | 19 int prng_idx, int hash_idx, |
20 unsigned long modulus_bitlen, | 20 unsigned long modulus_bitlen, |
21 unsigned char *out, unsigned long *outlen) | 21 unsigned char *out, unsigned long *outlen) |
22 { | 22 { |
23 unsigned char DB[1024], mask[sizeof(DB)], salt[sizeof(DB)], hash[sizeof(DB)]; | 23 unsigned char DB[1024], mask[sizeof(DB)], salt[sizeof(DB)], hash[sizeof(DB)]; |
24 unsigned long x, y, hLen, modulus_len; | 24 unsigned long x, y, hLen, modulus_len; |
102 } | 102 } |
103 /* 0xBC */ | 103 /* 0xBC */ |
104 out[y] = 0xBC; | 104 out[y] = 0xBC; |
105 | 105 |
106 /* now clear the 8*modulus_len - modulus_bitlen most significant bits */ | 106 /* now clear the 8*modulus_len - modulus_bitlen most significant bits */ |
107 out[0] &= 0xFF >> ((modulus_len<<3) - modulus_bitlen); | 107 out[0] &= 0xFF >> ((modulus_len<<3) - (modulus_bitlen-1)); |
108 | 108 |
109 /* store output size */ | 109 /* store output size */ |
110 *outlen = modulus_len; | 110 *outlen = modulus_len; |
111 | 111 |
112 #ifdef CLEAN_STACK | 112 #ifdef CLEAN_STACK |