ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-1.asc,
and RFC 2437.
- Copyright notice: All code, including the SILC PKCS API code that is
- not part of the Mozilla code, falls under the same license (MPL or GPL)
- found attached to this file, below.
+ Copyright notice: All code in this file, including the SILC PKCS API
+ code that is not part of the Mozilla code, falls under the same license
+ (MPL or GPL) found attached to this file, below.
*/
/*
* the rules defined in PKCS #1.
*/
static unsigned char *
-RSA_FormatOneBlock(unsigned int modulusLen, RSA_BlockType blockType,
- unsigned char *data, unsigned int data_len)
+RSA_FormatOneBlock(uint32 modulusLen, RSA_BlockType blockType,
+ unsigned char *data, uint32 data_len)
{
unsigned char *block;
unsigned char *bp;
int padLen;
+ int i;
block = (unsigned char *) silc_malloc(modulusLen);
if (block == NULL)
* Blocks intended for public-key operation.
*/
case RSA_BlockPublic:
-
- /* XXX For now we can't do this because we can't get the
- SilcRNG object down to this level. */
- silc_free(block);
- return NULL;
-
-#if 0
- int i;
-
/*
* 0x00 || BT || Pad || 0x00 || ActualData
* 1 1 padLen 1 data_len
for (i = 0; i < padLen; i++) {
/* Pad with non-zero random data. */
do {
- RNG_GenerateGlobalRandomBytes(bp + i, 1);
+ silc_rng_global_get_byte(bp + i);
} while (bp[i] == RSA_BLOCK_AFTER_PAD_OCTET);
}
bp += padLen;
*bp++ = RSA_BLOCK_AFTER_PAD_OCTET;
memcpy(bp, data, data_len);
-#endif
-
break;
default:
}
static int
-RSA_FormatBlock(unsigned char **result, unsigned int *result_len,
- unsigned int modulusLen,
+RSA_FormatBlock(unsigned char **result, uint32 *result_len,
+ uint32 modulusLen,
RSA_BlockType blockType, unsigned char *data,
- unsigned int data_len)
+ uint32 data_len)
{
/*
* XXX For now assume that the data length fits in a single
*/
unsigned char *
RSA_DecodeOneBlock(unsigned char *data,
- unsigned int modulusLen,
- unsigned int expectedLen,
+ uint32 modulusLen,
+ uint32 expectedLen,
RSA_BlockType bt,
- unsigned int *pResultLen)
+ uint32 *pResultLen)
{
RSA_BlockType blockType;
unsigned char *dp, *res;
- unsigned int i, len = 0;
+ uint32 i, len = 0;
dp = data;
if (dp[0] != RSA_BLOCK_FIRST_OCTET) {
SilcInt mp_tmp;
SilcInt mp_dst;
unsigned char *padded;
- unsigned int padded_len, len = key->bits / 8;
+ uint32 padded_len, len = key->bits / 8;
/* Pad data */
if (!RSA_FormatBlock(&padded, &padded_len, len,
SilcInt mp_tmp;
SilcInt mp_dst;
unsigned char *padded, *unpadded;
- unsigned int padded_len;
+ uint32 padded_len;
silc_mp_init_set_ui(&mp_tmp, 0);
silc_mp_init_set_ui(&mp_dst, 0);
SilcInt mp_tmp;
SilcInt mp_dst;
unsigned char *padded;
- unsigned int padded_len;
- unsigned int len = key->bits / 8;
+ uint32 padded_len;
+ uint32 len = key->bits / 8;
/* Pad data */
if (!RSA_FormatBlock(&padded, &padded_len, len, RSA_BlockPrivate,
SilcInt mp_tmp2;
SilcInt mp_dst;
unsigned char *verify, *unpadded;
- unsigned int verify_len, len = key->bits / 8;
+ uint32 verify_len, len = key->bits / 8;
silc_mp_init_set_ui(&mp_tmp2, 0);
silc_mp_init_set_ui(&mp_dst, 0);