source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/rsa/rsa_asn1.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 2000-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/bn.h>
13#include <openssl/x509.h>
14#include <openssl/asn1t.h>
15#include "rsa_locl.h"
16
17/* Override the default free and new methods */
18static int rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
19 void *exarg)
20{
21 if (operation == ASN1_OP_NEW_PRE) {
22 *pval = (ASN1_VALUE *)RSA_new();
23 if (*pval != NULL)
24 return 2;
25 return 0;
26 } else if (operation == ASN1_OP_FREE_PRE) {
27 RSA_free((RSA *)*pval);
28 *pval = NULL;
29 return 2;
30 }
31 return 1;
32}
33
34ASN1_SEQUENCE_cb(RSAPrivateKey, rsa_cb) = {
35 ASN1_SIMPLE(RSA, version, LONG),
36 ASN1_SIMPLE(RSA, n, BIGNUM),
37 ASN1_SIMPLE(RSA, e, BIGNUM),
38 ASN1_SIMPLE(RSA, d, CBIGNUM),
39 ASN1_SIMPLE(RSA, p, CBIGNUM),
40 ASN1_SIMPLE(RSA, q, CBIGNUM),
41 ASN1_SIMPLE(RSA, dmp1, CBIGNUM),
42 ASN1_SIMPLE(RSA, dmq1, CBIGNUM),
43 ASN1_SIMPLE(RSA, iqmp, CBIGNUM)
44} ASN1_SEQUENCE_END_cb(RSA, RSAPrivateKey)
45
46
47ASN1_SEQUENCE_cb(RSAPublicKey, rsa_cb) = {
48 ASN1_SIMPLE(RSA, n, BIGNUM),
49 ASN1_SIMPLE(RSA, e, BIGNUM),
50} ASN1_SEQUENCE_END_cb(RSA, RSAPublicKey)
51
52ASN1_SEQUENCE(RSA_PSS_PARAMS) = {
53 ASN1_EXP_OPT(RSA_PSS_PARAMS, hashAlgorithm, X509_ALGOR,0),
54 ASN1_EXP_OPT(RSA_PSS_PARAMS, maskGenAlgorithm, X509_ALGOR,1),
55 ASN1_EXP_OPT(RSA_PSS_PARAMS, saltLength, ASN1_INTEGER,2),
56 ASN1_EXP_OPT(RSA_PSS_PARAMS, trailerField, ASN1_INTEGER,3)
57} ASN1_SEQUENCE_END(RSA_PSS_PARAMS)
58
59IMPLEMENT_ASN1_FUNCTIONS(RSA_PSS_PARAMS)
60
61ASN1_SEQUENCE(RSA_OAEP_PARAMS) = {
62 ASN1_EXP_OPT(RSA_OAEP_PARAMS, hashFunc, X509_ALGOR, 0),
63 ASN1_EXP_OPT(RSA_OAEP_PARAMS, maskGenFunc, X509_ALGOR, 1),
64 ASN1_EXP_OPT(RSA_OAEP_PARAMS, pSourceFunc, X509_ALGOR, 2),
65} ASN1_SEQUENCE_END(RSA_OAEP_PARAMS)
66
67IMPLEMENT_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)
68
69IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPrivateKey, RSAPrivateKey)
70
71IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPublicKey, RSAPublicKey)
72
73RSA *RSAPublicKey_dup(RSA *rsa)
74{
75 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPublicKey), rsa);
76}
77
78RSA *RSAPrivateKey_dup(RSA *rsa)
79{
80 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPrivateKey), rsa);
81}
Note: See TracBrowser for help on using the repository browser.