Botan: Botan::CVC_EAC Namespace Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Functions
Botan::CVC_EAC Namespace Reference

## Functions
EAC1_1_ADO | create_ado_req (Private_Key const &key, EAC1_1_Req const &req, ASN1_Car const &car, RandomNumberGenerator &rng)
EAC1_1_Req | create_cvc_req (Private_Key const &key, ASN1_Chr const &chr, std::string const &hash_alg, RandomNumberGenerator &rng)
EAC1_1_CVC | create_self_signed_cert (Private_Key const &key, EAC1_1_CVC_Options const &opt, RandomNumberGenerator &rng)

## Detailed Description

This namespace represents general EAC 1.1 convenience functions.

## Function Documentation

EAC1_1_ADO BOTAN_DLL Botan::CVC_EAC::create_ado_req | ( | Private_Key const & | priv_key,
|  | EAC1_1_Req const & | req,
|  | ASN1_Car const & | car,
|  | RandomNumberGenerator & | rng
| ) |  |

Create an ADO from a request object.

Parameters

  priv_key | the private key used to sign the ADO
  req | the request forming the body of the ADO
  car | the CAR forming the body of the ADO, i.e. the CHR of the entity associated with the provided private key
  rng | the rng to use

Definition at line 156 of file cvc_self.cpp.

References Botan::EAC_Signed_Object::BER_encode(), Botan::DER_Encoder::encode(), Botan::DER_Encoder::get_contents(), Botan::EAC1_1_ADO::make_signed(), Botan::AlgorithmIdentifier::oid, and Botan::EAC_Signed_Object::signature_algorithm().

160 {
161
162 ECDSA_PrivateKey const* priv_key = dynamic_cast<ECDSA_PrivateKey const*>(&key);
163 if (priv_key == 0)
164 {
165 throw Invalid_Argument("CVC_EAC::create_self_signed_cert(): unsupported key type");
166 }
167 std::string padding_and_hash = padding_and_hash_from_oid(req.signature_algorithm().oid);
168 PK_Signer signer(*priv_key, padding_and_hash);
169 SecureVector<byte> tbs_bits = req.BER_encode();
170 tbs_bits += DER_Encoder().encode(car).get_contents();
171
172 MemoryVector<byte> signed_cert =
173 EAC1_1_ADO::make_signed(signer, tbs_bits, rng);
174
175 DataSource_Memory source(signed_cert);
176 return EAC1_1_ADO(source);
177 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20

EAC1_1_Req BOTAN_DLL Botan::CVC_EAC::create_cvc_req | ( | Private_Key const & | priv_key,
|  | ASN1_Chr const & | chr,
|  | std::string const & | hash_alg,
|  | RandomNumberGenerator & | rng
| ) |  |

Create a CVC request. The key encoding will be according to the provided private key.

Parameters

  priv_key | the private key associated with the requesting entity
  chr | the chr to appear in the certificate (to be provided without sequence number)
  hash_alg | the string defining the hash algorithm to be used for the creation of the signature
  rng | the rng to use

Returns
  the new request

Definition at line 119 of file cvc_self.cpp.

References Botan::ECDSA_PublicKey::algo_name(), Botan::APPLICATION, Botan::DER_Encoder::encode(), Botan::DER_Encoder::get_contents(), Botan::OIDS::lookup(), Botan::EAC1_1_gen_CVC< Derived >::make_signed(), Botan::OCTET_STRING, Botan::AlgorithmIdentifier::oid, Botan::MemoryRegion< T >::push_back(), Botan::DER_Encoder::raw_bytes(), and Botan::AlgorithmIdentifier::USE_NULL_PARAM.

Referenced by Botan::DE_EAC::create_cvc_req().

123 {
124
125 ECDSA_PrivateKey const* priv_key = dynamic_cast<ECDSA_PrivateKey const*>(&key);
126 if (priv_key == 0)
127 {
128 throw Invalid_Argument("CVC_EAC::create_self_signed_cert(): unsupported key type");
129 }
130 AlgorithmIdentifier sig_algo;
131 std::string padding_and_hash("EMSA1_BSI(" + hash_alg + ")");
132 sig_algo.oid = OIDS::lookup(priv_key->algo_name() + "/" + padding_and_hash);
133 sig_algo = AlgorithmIdentifier(sig_algo.oid, AlgorithmIdentifier::USE_NULL_PARAM);
134
135 PK_Signer signer(*priv_key, padding_and_hash);
136
137 MemoryVector<byte> enc_public_key = eac_1_1_encoding(priv_key, sig_algo.oid);
138
139 MemoryVector<byte> enc_cpi;
140 enc_cpi.push_back(0x00);
141 MemoryVector<byte> tbs = DER_Encoder()
142 .encode(enc_cpi, OCTET_STRING, ASN1_Tag(41), APPLICATION)
143 .raw_bytes(enc_public_key)
144 .encode(chr)
145 .get_contents();
146
147 MemoryVector<byte> signed_cert =
148 EAC1_1_gen_CVC<EAC1_1_Req>::make_signed(signer,
149 EAC1_1_gen_CVC<EAC1_1_Req>::build_cert_body(tbs),
150 rng);
151
152 DataSource_Memory source(signed_cert);
153 return EAC1_1_Req(source);
154 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::OCTET_STRING
Definition: asn1_int.h:31
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:31
Botan::EAC1_1_gen_CVC< EAC1_1_Req >::make_signed
static MemoryVector< byte > make_signed(PK_Signer &signer, const MemoryRegion< byte > &tbs_bits, RandomNumberGenerator &rng)
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_int.h:19
Botan::APPLICATION
Definition: asn1_int.h:21
Botan::EAC1_1_gen_CVC< EAC1_1_Req >::build_cert_body
static SecureVector< byte > build_cert_body(MemoryRegion< byte > const &tbs)

EAC1_1_CVC BOTAN_DLL Botan::CVC_EAC::create_self_signed_cert | ( | Private_Key const & | key,
|  | EAC1_1_CVC_Options const & | opts,
|  | RandomNumberGenerator & | rng
| ) |  |

Create a selfsigned CVCA

Parameters

  rng | the rng to use
  key | the ECDSA private key to be used to sign the certificate
  opts | used to set several parameters. Necessary are: car, holder_auth_templ, hash_alg, ced, cex and hash_alg

Returns
  the self signed certificate

Definition at line 90 of file cvc_self.cpp.

References Botan::ECDSA_PublicKey::algo_name(), Botan::EAC1_1_CVC_Options::car, Botan::EAC1_1_CVC_Options::ced, Botan::EAC1_1_CVC_Options::cex, Botan::EAC1_1_CVC_Options::hash_alg, Botan::EAC1_1_CVC_Options::holder_auth_templ, Botan::OIDS::lookup(), Botan::make_cvc_cert(), Botan::AlgorithmIdentifier::USE_NULL_PARAM, and Botan::ASN1_EAC_String::value().

Referenced by Botan::DE_EAC::create_cvca().

93 {
94 // NOTE: we ignore the value of opt.chr
95
96 const ECDSA_PrivateKey* priv_key = dynamic_cast<const ECDSA_PrivateKey*>(&key);
97
98 if(priv_key == 0)
99 throw Invalid_Argument("CVC_EAC::create_self_signed_cert(): unsupported key type");
100
101 ASN1_Chr chr(opt.car.value());
102
103 AlgorithmIdentifier sig_algo;
104 std::string padding_and_hash("EMSA1_BSI(" + opt.hash_alg + ")");
105 sig_algo.oid = OIDS::lookup(priv_key->algo_name() + "/" + padding_and_hash);
106 sig_algo = AlgorithmIdentifier(sig_algo.oid, AlgorithmIdentifier::USE_NULL_PARAM);
107
108 PK_Signer signer(*priv_key, padding_and_hash);
109
110 MemoryVector<byte> enc_public_key = eac_1_1_encoding(priv_key, sig_algo.oid);
111
112 return make_cvc_cert(signer,
113 enc_public_key,
114 opt.car, chr,
115 opt.holder_auth_templ,
116 opt.ced, opt.cex, rng);
117 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:31
Botan::make_cvc_cert
EAC1_1_CVC make_cvc_cert(PK_Signer &signer, MemoryRegion< byte > const &public_key, ASN1_Car const &car, ASN1_Chr const &chr, byte holder_auth_templ, ASN1_Ced ced, ASN1_Cex cex, RandomNumberGenerator &rng)
Definition: cvc_cert.cpp:98