nrfxlib API 3.3.99
Loading...
Searching...
No Matches
ocrypto_rsa_key.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 - 2025 Nordic Semiconductor ASA
3 * Copyright (c) since 2013 Oberon microsystems AG
4 *
5 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
6 */
7
8
31#ifndef OCRYPTO_RSA_KEY_H
32#define OCRYPTO_RSA_KEY_H
33
34#include <stddef.h>
35#include <stdint.h>
36
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42
46#define ocrypto_rsa_PUBLIC_EXPONENT 65537 // 2^16 + 1
47
48
58typedef struct {
60 uint32_t n[32];
61 // e = 65537
64
68typedef struct {
70 uint32_t n[32];
71 uint32_t d[32]; // x^(e*d) mod n == x
74
78typedef struct {
80 uint32_t n[32];
81 uint32_t p[16], q[16]; // primes, p*q = n
82 uint32_t dp[16], dq[16]; // d mod (p-1), d mod (q-1)
83 uint32_t qinv[16]; // 1/q mod p
98typedef struct {
100 uint32_t n[64];
101 // e = 65537
104
108typedef struct {
110 uint32_t n[64];
111 uint32_t d[64]; // x^(e*d) mod n == x
114
118typedef struct {
120 uint32_t n[64];
121 uint32_t p[32], q[32]; // primes, p*q = n
122 uint32_t dp[32], dq[32]; // d mod (p-1), d mod (q-1)
123 uint32_t qinv[32]; // 1/q mod p
148 const uint8_t *n, size_t n_len);
149
164 const uint8_t *n, size_t n_len,
165 const uint8_t *d, size_t d_len);
166
187 const uint8_t *p, size_t p_len,
188 const uint8_t *q, size_t q_len,
189 const uint8_t *dp, size_t dp_len,
190 const uint8_t *dq, size_t dq_len,
191 const uint8_t *qinv, size_t qi_len);
214 const uint8_t *n, size_t n_len);
215
229 const uint8_t *n, size_t n_len,
230 const uint8_t *d, size_t d_len);
231
252 const uint8_t *p, size_t p_len,
253 const uint8_t *q, size_t q_len,
254 const uint8_t *dp, size_t dp_len,
255 const uint8_t *dq, size_t dq_len,
256 const uint8_t *qinv, size_t qi_len);
259#ifdef __cplusplus
260}
261#endif
262
263#endif
264
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:78
Definition ocrypto_rsa_key.h:68
Definition ocrypto_rsa_key.h:58
Definition ocrypto_rsa_key.h:118
Definition ocrypto_rsa_key.h:108
Definition ocrypto_rsa_key.h:98