blob: 3d0556b1606f2c08941083e09a4bf8f9f7634d3d [file] [log] [blame]
Dees Troybb4c0cb2013-11-02 20:25:14 +00001/* rsa.h
2**
3** Copyright 2008, The Android Open Source Project
4**
5** Redistribution and use in source and binary forms, with or without
6** modification, are permitted provided that the following conditions are met:
7** * Redistributions of source code must retain the above copyright
8** notice, this list of conditions and the following disclaimer.
9** * Redistributions in binary form must reproduce the above copyright
10** notice, this list of conditions and the following disclaimer in the
11** documentation and/or other materials provided with the distribution.
12** * Neither the name of Google Inc. nor the names of its contributors may
13** be used to endorse or promote products derived from this software
14** without specific prior written permission.
15**
16** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR
17** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19** EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
Ethan Yonker1e4a1992014-11-06 09:05:01 -060028#ifndef SYSTEM_CORE_INCLUDE_MINCRYPT_RSA_H_
29#define SYSTEM_CORE_INCLUDE_MINCRYPT_RSA_H_
Dees Troybb4c0cb2013-11-02 20:25:14 +000030
31#include <inttypes.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#define RSANUMBYTES 256 /* 2048 bit key length */
38#define RSANUMWORDS (RSANUMBYTES / sizeof(uint32_t))
39
40typedef struct RSAPublicKey {
41 int len; /* Length of n[] in number of uint32_t */
42 uint32_t n0inv; /* -1 / n[0] mod 2^32 */
43 uint32_t n[RSANUMWORDS]; /* modulus as little endian array */
44 uint32_t rr[RSANUMWORDS]; /* R^2 as little endian array */
45 int exponent; /* 3 or 65537 */
46} RSAPublicKey;
47
48int RSA_verify(const RSAPublicKey *key,
49 const uint8_t* signature,
50 const int len,
51 const uint8_t* hash,
52 const int hash_len);
53
54#ifdef __cplusplus
55}
56#endif
57
Ethan Yonker1e4a1992014-11-06 09:05:01 -060058#endif // SYSTEM_CORE_INCLUDE_MINCRYPT_RSA_H_