]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - test_src/main-rsaes_oaep-test.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / test_src / main-rsaes_oaep-test.c
index 26cb449697d6c7c6bed47601c8ef90e954539b73..3ed60dd78af89c7fb84f78a7fb2948afd094350a 100644 (file)
@@ -1,7 +1,7 @@
 /* main-dsa-test.c */
 /*
     This file is part of the ARM-Crypto-Lib.
-    Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de)
+    Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
 
     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
@@ -32,7 +32,7 @@
 
 #include "performance_test.h"
 
-const charalgo_name = "RSAES-OAEP";
+const char *algo_name = "RSAES-OAEP";
 
 #define BIGINT_CEIL(x) ((((x) + sizeof(bigint_word_t) - 1) / sizeof(bigint_word_t)) *  sizeof(bigint_word_t))
 #define BIGINT_OFF(x) ((sizeof(bigint_word_t) - (x) % sizeof(bigint_word_t)) % sizeof(bigint_word_t))
@@ -356,7 +356,7 @@ uint8_t convert_nibble(uint8_t c){
 
 const char *block_ignore_string=" \t\r\n,;";
 #define BUFFER_LIMIT 120
-uint16_t read_os(void* dst, uint16_t length, const char* ignore_string){
+uint16_t read_os(void *dst, uint16_t length, const char *ignore_string){
        uint16_t counter = 0;
        uint16_t c;
        uint8_t v, tmp = 0, idx = 0;
@@ -389,7 +389,7 @@ uint16_t read_os(void* dst, uint16_t length, const char* ignore_string){
        return counter;
 }
 
-uint16_t own_atou(const charstr){
+uint16_t own_atou(const char *str){
        uint16_t r=0;
        while(*str && *str >= '0' && *str <= '9'){
                r *= 10;
@@ -398,7 +398,7 @@ uint16_t own_atou(const char* str){
        return r;
 }
 
-uint8_t read_bigint(bigint_t* a, char* prompt){
+uint8_t read_bigint(bigint_t *a, char *prompt){
        uint16_t read_length, actual_length;
        uint8_t off;
        uint8_t *buffer;
@@ -422,7 +422,7 @@ uint8_t read_bigint(bigint_t* a, char* prompt){
                return 1;
        }
        a->wordv = (bigint_word_t*)buffer;
-       a->length_B = (read_length + sizeof(bigint_word_t) - 1) / sizeof(bigint_word_t);
+       a->length_W = (read_length + sizeof(bigint_word_t) - 1) / sizeof(bigint_word_t);
        a->info = 0;
        bigint_changeendianess(a);
        bigint_adjust(a);
@@ -490,8 +490,8 @@ uint8_t read_key_conv(void){
        return r;
 }
 
-uint8_t load_bigint_from_os(bigint_ta, PGM_VOID_P os, uint16_t length_B){
-       a->length_B = BIGINT_CEIL(length_B) / sizeof(bigint_word_t);
+uint8_t load_bigint_from_os(bigint_t *a, PGM_VOID_P os, uint16_t length_B){
+       a->length_W = BIGINT_CEIL(length_B) / sizeof(bigint_word_t);
        a->wordv = malloc(BIGINT_CEIL(length_B));
        if(!a->wordv){
                cli_putstr_P(PSTR("\r\nOOM!\r\n"));
@@ -531,12 +531,15 @@ void quick_test(void){
        uint8_t *ciphertext, *plaintext, rc;
        uint8_t seed[sizeof(SEED)];
        uint16_t clen, plen;
-       ciphertext = malloc(clen = pub_key.modulus.length_B * sizeof(bigint_word_t));
-       plaintext = malloc(pub_key.modulus.length_B * sizeof(bigint_word_t));
+       if(!keys_allocated){
+               load_fix_rsa();
+       }
+       ciphertext = malloc(clen = pub_key.modulus.length_W * sizeof(bigint_word_t));
+       plaintext = malloc(pub_key.modulus.length_W * sizeof(bigint_word_t));
        memcpy_P(plaintext, MSG, sizeof(MSG));
        memcpy_P(seed, SEED, sizeof(SEED));
        cli_putstr_P(PSTR("\r\nplaintext:"));
-       cli_hexdump_block(plaintext, sizeof(MSG), 4, 8);
+       cli_hexdump_block(plaintext, sizeof(MSG), 4, 16);
        cli_putstr_P(PSTR("\r\nencrypting: ..."));
        rc = rsa_encrypt_oaep(ciphertext, &clen, plaintext, sizeof(MSG), &pub_key, NULL, NULL, seed);
        if(rc){