summaryrefslogtreecommitdiff
path: root/libc/rsa.h
blob: e420ad75084e149f3fe694f8b79a299705a0d10e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2008 Google Inc. All Rights Reserved.
// Author: mschilder@google.com (Marius Schilder)

#ifndef _EMBEDDED_RSA_H_
#define _EMBEDDED_RSA_H_

#include <inttypes.h>

#ifdef __cplusplus
extern "C" {
#endif  // __cplusplus

#define RSANUMBYTES 256  // 2048 bit key length
#define RSANUMWORDS (RSANUMBYTES / sizeof(uint32_t))

typedef struct RSAPublicKeyInstance {
  int len;  // Length of n[] in number of uint32_t
  uint32_t n0inv;  // -1 / n[0] mod 2^32
  uint32_t n[RSANUMWORDS];  // modulus as little endian array
  uint32_t rr[RSANUMWORDS];  // R^2 as little endian array
} RSAPublicKeyInstance;

typedef const RSAPublicKeyInstance * const RSAPublicKey;

int RSA_verify(RSAPublicKey mod,
               const uint8_t* signature,
               const int len,
               const uint8_t* sha);

#ifdef __cplusplus
}
#endif  // __cplusplus

#endif  // _EMBEDDED_RSA_H_