1 // Copyright 2008 Google Inc. All Rights Reserved. 2 // Author: mschilder@google.com (Marius Schilder) 3 4 #ifndef _EMBEDDED_RSA_H_ 5 #define _EMBEDDED_RSA_H_ 6 7 #include <inttypes.h> 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif // __cplusplus 12 13 #define RSANUMBYTES 256 // 2048 bit key length 14 #define RSANUMWORDS (RSANUMBYTES / sizeof(uint32_t)) 15 16 typedef struct RSAPublicKeyInstance { 17 int len; // Length of n[] in number of uint32_t 18 uint32_t n0inv; // -1 / n[0] mod 2^32 19 uint32_t n[RSANUMWORDS]; // modulus as little endian array 20 uint32_t rr[RSANUMWORDS]; // R^2 as little endian array 21 } RSAPublicKeyInstance; 22 23 typedef const RSAPublicKeyInstance * const RSAPublicKey; 24 25 int RSA_verify(RSAPublicKey mod, 26 const uint8_t* signature, 27 const int len, 28 const uint8_t* sha); 29 30 #ifdef __cplusplus 31 } 32 #endif // __cplusplus 33 34 #endif // _EMBEDDED_RSA_H_ 35