lubiXOXO
[hackover2013-badge-firmware.git] / drivers / rsa / rsa.h
1 /**************************************************************************/
2 /*!
3 @file rsa.h
4 @author Kyle Loudon
5 modified: microBuilder.eu
6 @date 4 January, 2010
7 @version 1.0
8
9 Basic RSA-encryption using 64-bit math (32-bit keys).
10
11 Based on the examples from "Mastering Algorithms with C" by
12 Kyle Loudon (O'Reilly, 1999).
13 */
14 /**************************************************************************/
15
16 #ifndef _RSA_H_
17 #define _RSA_H_
18
19 #include "projectconfig.h"
20
21 /* In a secure implementation, huge_t should be at least 400 decimal digits, *
22 * instead of the 20 provided by a 64-bit value. This means that key values *
23 * can be no longer than 10 digits in length in the current implementation. */
24 #if CFG_RSA_BITS == 64
25 typedef uint64_t huge_t;
26 #endif
27 #if CFG_RSA_BITS == 32
28 typedef uint32_t huge_t;
29 #endif
30
31 /* Structure for RSA public keys. */
32 typedef struct rsaPubKey_s
33 {
34 huge_t e;
35 huge_t n;
36 }
37 rsaPubKey_t;
38
39 /* Define a structure for RSA private keys. */
40 typedef struct rsaPriKey_s
41 {
42 huge_t d;
43 huge_t n;
44 }
45 rsaPriKey_t;
46
47 void rsaTest();
48 void rsaEncrypt(huge_t plaintext, huge_t *ciphertext, rsaPubKey_t pubkey);
49 void rsaDecrypt(huge_t ciphertext, huge_t *plaintext, rsaPriKey_t prikey);
50
51 #endif
This page took 0.044048 seconds and 5 git commands to generate.