X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=rsa%2Frsa_pkcs15.c;fp=rsa%2Frsa_pkcs15.c;h=0000000000000000000000000000000000000000;hb=cc6b183296a5852449e3324737e2a2dece788786;hp=b1ec7ca9c7e12dedc2f7a093d6ba44b7ff4de120;hpb=06d9213f132d05f61b65acc51de6f7ad1b42f48a;p=avr-crypto-lib.git diff --git a/rsa/rsa_pkcs15.c b/rsa/rsa_pkcs15.c deleted file mode 100644 index b1ec7ca..0000000 --- a/rsa/rsa_pkcs15.c +++ /dev/null @@ -1,134 +0,0 @@ -/* rsa_pkcs15.c */ -/* - This file is part of the ARM-Crypto-Lib. - Copyright (C) 2006-2011 Daniel Otte (daniel.otte@rub.de) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include -#include -#include -#include "bigint.h" -#include "rsa_basic.h" - -#define DEBUG 0 - -#if DEBUG -#include "bigint_io.h" -#include "cli.h" -#endif - -#include "random_dummy.h" - -uint16_t rsa_pkcs15_compute_padlength_B(bigint_t* modulus, uint16_t msg_length_B){ - return bigint_get_first_set_bit(modulus) / 8 + 1 - msg_length_B - 3; -} - -uint8_t rsa_encrypt_pkcs15(void* dest, uint16_t* out_length, const void* src, - uint16_t length_B, rsa_publickey_t* key, const void* pad){ - int16_t pad_length; - bigint_t x; - pad_length = rsa_pkcs15_compute_padlength_B(key->modulus, length_B); - if(pad_length<8){ -#if DEBUG - cli_putstr_P(PSTR("\r\nERROR: pad_length<8; pad_length: ")); - cli_hexdump_rev(&pad_length, 2); -#endif - return 2; /* message to long */ - } - if(!pad){ -#if DEBUG - cli_putstr_P(PSTR("\r\nauto-generating pad ...")); -#endif - uint16_t i; - uint8_t c; - for(i=0; i=m_length){ - return 1; - } - ++idx; - while(((uint8_t*)x.wordv)[idx+pad_length]!=0 && (idx+pad_length)=m_length){ - return 2; - } - *out_length = m_length - idx - pad_length - 1; - if(pad){ -#if DEBUG - cli_putstr_P(PSTR("\r\npadding block:")); - cli_hexdump_block(((uint8_t*)x.wordv)+idx, pad_length, 4, 16); - cli_putstr_P(PSTR("\r\npad @ 0x")); - cli_hexdump_rev(&pad, 2); - cli_putstr_P(PSTR("\r\ndst @ 0x")); - cli_hexdump_rev(&dest, 2); -#endif - memcpy(pad, ((uint8_t*)x.wordv)+idx, pad_length); - } - memmove(dest, ((uint8_t*)x.wordv) + idx + pad_length + 1, m_length - idx - pad_length - 1); - - return 0; -} -