Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
openssl-compat.c
Go to the documentation of this file.
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#include "openssl-compat.h"
11#if OPENSSL_VERSION_NUMBER < 0x10100000L
12
13int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) {
14 /* If the fields n and e in r are NULL, the corresponding input
15 * parameters MUST be non-NULL for n and e. d may be
16 * left NULL (in case only the public key is used).
17 */
18 if ((r->n == NULL && n == NULL) || (r->e == NULL && e == NULL))
19 return 0;
20
21 if (n != NULL) {
22 BN_free(r->n);
23 r->n = n;
24 }
25 if (e != NULL) {
26 BN_free(r->e);
27 r->e = e;
28 }
29 if (d != NULL) {
30 BN_free(r->d);
31 r->d = d;
32 }
33
34 return 1;
35}
36
37void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e,
38 const BIGNUM **d) {
39 if (n != NULL)
40 *n = r->n;
41 if (e != NULL)
42 *e = r->e;
43 if (d != NULL)
44 *d = r->d;
45}
46
47void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) {
48 if (p != NULL)
49 *p = r->p;
50 if (q != NULL)
51 *q = r->q;
52}
53
54void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1,
55 const BIGNUM **iqmp) {
56 if (dmp1 != NULL)
57 *dmp1 = r->dmp1;
58 if (dmq1 != NULL)
59 *dmq1 = r->dmq1;
60 if (iqmp != NULL)
61 *iqmp = r->iqmp;
62}
63
64int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) {
65 if ((sig->r == NULL && r == NULL) || (sig->s == NULL && s == NULL)) {
66 return 0;
67 }
68
69 if (r != NULL) {
70 BN_free(sig->r);
71 sig->r = r;
72 }
73 if (s != NULL) {
74 BN_free(sig->s);
75 sig->s = s;
76 }
77
78 return 1;
79}
80void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr,
81 const BIGNUM **ps) {
82 if (pr != NULL) {
83 *pr = sig->r;
84 }
85 if (ps != NULL) {
86 *ps = sig->s;
87 }
88}
89
90const STACK_OF(X509_EXTENSION) * X509_get0_extensions(const X509 *x) {
91 return x->cert_info->extensions;
92}
93
94ASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex) {
95 return ex->object;
96}
97ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ex) {
98 return ex->value;
99}
100
101#endif /* OPENSSL_VERSION_NUMBER */
const mie::Vuint & p
Definition bn.cpp:27
const mie::Vuint & r
Definition bn.cpp:28
bignum_st BIGNUM
Definition bigint.hpp:7
ASN1_OCTET_STRING * X509_EXTENSION_get_data(X509_EXTENSION *ex)
void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp)
ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex)
const STACK_OF(X509_EXTENSION)
void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)
void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q)
int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d)
int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)
CK_ULONG d
char * s