All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
certificate-subject-description.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
9 #include "common.hpp"
10 
12 
13 #include "cryptopp.hpp"
14 
15 using namespace std;
16 using namespace CryptoPP;
17 
18 namespace ndn {
19 
20 void
21 CertificateSubjectDescription::encode(CryptoPP::BufferedTransformation& out) const
22 {
23  // RelativeDistinguishedName ::=
24  // SET OF AttributeTypeAndValue
25  //
26  // AttributeTypeAndValue ::= SEQUENCE {
27  // type AttributeType,
28  // value AttributeValue }
29  //
30  // AttributeType ::= OBJECT IDENTIFIER
31  //
32  // AttributeValue ::= ANY DEFINED BY AttributeType
33  DERSequenceEncoder attributeTypeAndValue(out);
34  {
35  m_oid.encode(attributeTypeAndValue);
36  DEREncodeTextString(attributeTypeAndValue, m_value, PRINTABLE_STRING);
37  }
38  attributeTypeAndValue.MessageEnd();
39 }
40 
41 void
42 CertificateSubjectDescription::decode(CryptoPP::BufferedTransformation& in)
43 {
44  // RelativeDistinguishedName ::=
45  // SET OF AttributeTypeAndValue
46  //
47  // AttributeTypeAndValue ::= SEQUENCE {
48  // type AttributeType,
49  // value AttributeValue }
50  //
51  // AttributeType ::= OBJECT IDENTIFIER
52  //
53  // AttributeValue ::= ANY DEFINED BY AttributeType
54 
55  BERSequenceDecoder attributeTypeAndValue(in);
56  {
57  m_oid.decode(attributeTypeAndValue);
58 
61  BERDecodeTextString(attributeTypeAndValue, m_value, PRINTABLE_STRING);
62  }
63  attributeTypeAndValue.MessageEnd();
64 }
65 
66 } // namespace ndn