nrfxlib API 2.8.99
Loading...
Searching...
No Matches
ocrypto_rsa_key.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 - 2024 Nordic Semiconductor ASA
3 * Copyright (c) since 2013 Oberon microsystems AG
4 *
5 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
6 */
7
8
20#ifndef OCRYPTO_RSA_KEY_H
21#define OCRYPTO_RSA_KEY_H
22
23#include <stddef.h>
24#include <stdint.h>
25
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31
35#define ocrypto_rsa_PUBLIC_EXPONENT 65537 // 2^16 + 1
36
37
46typedef struct {
48 uint32_t n[32];
49 // e = 65537
52
56typedef struct {
58 uint32_t n[32];
59 uint32_t d[32]; // x^(e*d) mod n == x
62
66typedef struct {
68 uint32_t n[32];
69 uint32_t p[16], q[16]; // primes, p*q = n
70 uint32_t dp[16], dq[16]; // d mod (p-1), d mod (q-1)
71 uint32_t qinv[16]; // 1/q mod p
85typedef struct {
87 uint32_t n[64];
88 // e = 65537
91
95typedef struct {
97 uint32_t n[64];
98 uint32_t d[64]; // x^(e*d) mod n == x
101
105typedef struct {
107 uint32_t n[64];
108 uint32_t p[32], q[32]; // primes, p*q = n
109 uint32_t dp[32], dq[32]; // d mod (p-1), d mod (q-1)
110 uint32_t qinv[32]; // 1/q mod p
134 const uint8_t *n, size_t n_len);
135
150 const uint8_t *n, size_t n_len,
151 const uint8_t *d, size_t d_len);
152
173 const uint8_t *p, size_t p_len,
174 const uint8_t *q, size_t q_len,
175 const uint8_t *dp, size_t dp_len,
176 const uint8_t *dq, size_t dq_len,
177 const uint8_t *qinv, size_t qi_len);
199 const uint8_t *n, size_t n_len);
200
214 const uint8_t *n, size_t n_len,
215 const uint8_t *d, size_t d_len);
216
237 const uint8_t *p, size_t p_len,
238 const uint8_t *q, size_t q_len,
239 const uint8_t *dp, size_t dp_len,
240 const uint8_t *dq, size_t dq_len,
241 const uint8_t *qinv, size_t qi_len);
244#ifdef __cplusplus
245}
246#endif
247
248#endif
249
int ocrypto_rsa1024_init_pub_key(ocrypto_rsa1024_pub_key *pk, const uint8_t *n, size_t n_len)
int ocrypto_rsa2048_init_pub_key(ocrypto_rsa2048_pub_key *pk, const uint8_t *n, size_t n_len)
int ocrypto_rsa1024_init_key(ocrypto_rsa1024_key *pk, const uint8_t *n, size_t n_len, const uint8_t *d, size_t d_len)
int ocrypto_rsa2048_init_crt_key(ocrypto_rsa2048_crt_key *sk, const uint8_t *p, size_t p_len, const uint8_t *q, size_t q_len, const uint8_t *dp, size_t dp_len, const uint8_t *dq, size_t dq_len, const uint8_t *qinv, size_t qi_len)
int ocrypto_rsa2048_init_key(ocrypto_rsa2048_key *sk, const uint8_t *n, size_t n_len, const uint8_t *d, size_t d_len)
int ocrypto_rsa1024_init_crt_key(ocrypto_rsa1024_crt_key *sk, const uint8_t *p, size_t p_len, const uint8_t *q, size_t q_len, const uint8_t *dp, size_t dp_len, const uint8_t *dq, size_t dq_len, const uint8_t *qinv, size_t qi_len)
Definition ocrypto_rsa_key.h:66
Definition ocrypto_rsa_key.h:56
Definition ocrypto_rsa_key.h:46
Definition ocrypto_rsa_key.h:105
Definition ocrypto_rsa_key.h:95
Definition ocrypto_rsa_key.h:85