source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/x509/x509cset.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 4.0 KB
Line 
1/*
2 * Copyright 2001-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 <stdio.h>
11#include "internal/cryptlib.h"
12#include <openssl/asn1.h>
13#include <openssl/objects.h>
14#include <openssl/evp.h>
15#include <openssl/x509.h>
16#include "internal/x509_int.h"
17
18int X509_CRL_set_version(X509_CRL *x, long version)
19{
20 if (x == NULL)
21 return (0);
22 if (x->crl.version == NULL) {
23 if ((x->crl.version = ASN1_INTEGER_new()) == NULL)
24 return (0);
25 }
26 return (ASN1_INTEGER_set(x->crl.version, version));
27}
28
29int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name)
30{
31 if (x == NULL)
32 return (0);
33 return (X509_NAME_set(&x->crl.issuer, name));
34}
35
36int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm)
37{
38 if (x == NULL)
39 return 0;
40 return x509_set1_time(&x->crl.lastUpdate, tm);
41}
42
43int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm)
44{
45 if (x == NULL)
46 return 0;
47 return x509_set1_time(&x->crl.nextUpdate, tm);
48}
49
50int X509_CRL_sort(X509_CRL *c)
51{
52 int i;
53 X509_REVOKED *r;
54 /*
55 * sort the data so it will be written in serial number order
56 */
57 sk_X509_REVOKED_sort(c->crl.revoked);
58 for (i = 0; i < sk_X509_REVOKED_num(c->crl.revoked); i++) {
59 r = sk_X509_REVOKED_value(c->crl.revoked, i);
60 r->sequence = i;
61 }
62 c->crl.enc.modified = 1;
63 return 1;
64}
65
66int X509_CRL_up_ref(X509_CRL *crl)
67{
68 int i;
69
70 if (CRYPTO_atomic_add(&crl->references, 1, &i, crl->lock) <= 0)
71 return 0;
72
73 REF_PRINT_COUNT("X509_CRL", crl);
74 REF_ASSERT_ISNT(i < 2);
75 return ((i > 1) ? 1 : 0);
76}
77
78long X509_CRL_get_version(const X509_CRL *crl)
79{
80 return ASN1_INTEGER_get(crl->crl.version);
81}
82
83const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl)
84{
85 return crl->crl.lastUpdate;
86}
87
88const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl)
89{
90 return crl->crl.nextUpdate;
91}
92
93#if OPENSSL_API_COMPAT < 0x10100000L
94ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl)
95{
96 return crl->crl.lastUpdate;
97}
98
99ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl)
100{
101 return crl->crl.nextUpdate;
102}
103#endif
104
105X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl)
106{
107 return crl->crl.issuer;
108}
109
110const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl)
111{
112 return crl->crl.extensions;
113}
114
115STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl)
116{
117 return crl->crl.revoked;
118}
119
120void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,
121 const X509_ALGOR **palg)
122{
123 if (psig != NULL)
124 *psig = &crl->signature;
125 if (palg != NULL)
126 *palg = &crl->sig_alg;
127}
128
129int X509_CRL_get_signature_nid(const X509_CRL *crl)
130{
131 return OBJ_obj2nid(crl->sig_alg.algorithm);
132}
133
134const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x)
135{
136 return x->revocationDate;
137}
138
139int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm)
140{
141 ASN1_TIME *in;
142
143 if (x == NULL)
144 return (0);
145 in = x->revocationDate;
146 if (in != tm) {
147 in = ASN1_STRING_dup(tm);
148 if (in != NULL) {
149 ASN1_TIME_free(x->revocationDate);
150 x->revocationDate = in;
151 }
152 }
153 return (in != NULL);
154}
155
156const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x)
157{
158 return &x->serialNumber;
159}
160
161int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial)
162{
163 ASN1_INTEGER *in;
164
165 if (x == NULL)
166 return (0);
167 in = &x->serialNumber;
168 if (in != serial)
169 return ASN1_STRING_copy(in, serial);
170 return 1;
171}
172
173const STACK_OF(X509_EXTENSION) *X509_REVOKED_get0_extensions(const X509_REVOKED *r)
174{
175 return r->extensions;
176}
177
178int i2d_re_X509_CRL_tbs(X509_CRL *crl, unsigned char **pp)
179{
180 crl->crl.enc.modified = 1;
181 return i2d_X509_CRL_INFO(&crl->crl, pp);
182}
Note: See TracBrowser for help on using the repository browser.