source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/asn1/x_algor.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: 2.5 KB
Line 
1/*
2 * Copyright 1998-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 <stddef.h>
11#include <openssl/x509.h>
12#include <openssl/asn1.h>
13#include <openssl/asn1t.h>
14#include "internal/evp_int.h"
15
16ASN1_SEQUENCE(X509_ALGOR) = {
17 ASN1_SIMPLE(X509_ALGOR, algorithm, ASN1_OBJECT),
18 ASN1_OPT(X509_ALGOR, parameter, ASN1_ANY)
19} ASN1_SEQUENCE_END(X509_ALGOR)
20
21ASN1_ITEM_TEMPLATE(X509_ALGORS) =
22 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, algorithms, X509_ALGOR)
23ASN1_ITEM_TEMPLATE_END(X509_ALGORS)
24
25IMPLEMENT_ASN1_FUNCTIONS(X509_ALGOR)
26IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(X509_ALGORS, X509_ALGORS, X509_ALGORS)
27IMPLEMENT_ASN1_DUP_FUNCTION(X509_ALGOR)
28
29int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval)
30{
31 if (!alg)
32 return 0;
33 if (ptype != V_ASN1_UNDEF) {
34 if (alg->parameter == NULL)
35 alg->parameter = ASN1_TYPE_new();
36 if (alg->parameter == NULL)
37 return 0;
38 }
39 if (alg) {
40 ASN1_OBJECT_free(alg->algorithm);
41 alg->algorithm = aobj;
42 }
43 if (ptype == 0)
44 return 1;
45 if (ptype == V_ASN1_UNDEF) {
46 ASN1_TYPE_free(alg->parameter);
47 alg->parameter = NULL;
48 } else
49 ASN1_TYPE_set(alg->parameter, ptype, pval);
50 return 1;
51}
52
53void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype,
54 const void **ppval, const X509_ALGOR *algor)
55{
56 if (paobj)
57 *paobj = algor->algorithm;
58 if (pptype) {
59 if (algor->parameter == NULL) {
60 *pptype = V_ASN1_UNDEF;
61 return;
62 } else
63 *pptype = algor->parameter->type;
64 if (ppval)
65 *ppval = algor->parameter->value.ptr;
66 }
67}
68
69/* Set up an X509_ALGOR DigestAlgorithmIdentifier from an EVP_MD */
70
71void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md)
72{
73 int param_type;
74
75 if (md->flags & EVP_MD_FLAG_DIGALGID_ABSENT)
76 param_type = V_ASN1_UNDEF;
77 else
78 param_type = V_ASN1_NULL;
79
80 X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_type(md)), param_type, NULL);
81
82}
83
84int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b)
85{
86 int rv;
87 rv = OBJ_cmp(a->algorithm, b->algorithm);
88 if (rv)
89 return rv;
90 if (!a->parameter && !b->parameter)
91 return 0;
92 return ASN1_TYPE_cmp(a->parameter, b->parameter);
93}
Note: See TracBrowser for help on using the repository browser.