| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| /** |
| * Copyright (C) 2013 Regents of the University of California. |
| * @author: Yingdi Yu <yingdi@cs.ucla.edu> |
| * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
| * See COPYING for copyright and distribution information. |
| */ |
| |
| #include <ndn-cpp/security/certificate/certificate-subject-description.hpp> |
| #include <cryptopp/asn.h> |
| |
| using namespace std; |
| using namespace CryptoPP; |
| |
| namespace ndn { |
| |
| void |
| CertificateSubjectDescription::encode(CryptoPP::BufferedTransformation &out) const |
| { |
| // RelativeDistinguishedName ::= |
| // SET OF AttributeTypeAndValue |
| // |
| // AttributeTypeAndValue ::= SEQUENCE { |
| // type AttributeType, |
| // value AttributeValue } |
| // |
| // AttributeType ::= OBJECT IDENTIFIER |
| // |
| // AttributeValue ::= ANY DEFINED BY AttributeType |
| DERSequenceEncoder attributeTypeAndValue(out); |
| { |
| oid_.encode(attributeTypeAndValue); |
| DEREncodeTextString(attributeTypeAndValue, value_, PRINTABLE_STRING); |
| } |
| attributeTypeAndValue.MessageEnd(); |
| } |
| |
| void |
| CertificateSubjectDescription::decode(CryptoPP::BufferedTransformation &in) |
| { |
| // RelativeDistinguishedName ::= |
| // SET OF AttributeTypeAndValue |
| // |
| // AttributeTypeAndValue ::= SEQUENCE { |
| // type AttributeType, |
| // value AttributeValue } |
| // |
| // AttributeType ::= OBJECT IDENTIFIER |
| // |
| // AttributeValue ::= ANY DEFINED BY AttributeType |
| |
| BERSequenceDecoder attributeTypeAndValue(in); |
| { |
| oid_.decode(attributeTypeAndValue); |
| |
| /// @todo May be add more intelligent processing, since the following |
| /// may fail if somebody encoded attribute that uses non PRINTABLE_STRING as value |
| BERDecodeTextString(attributeTypeAndValue, value_, PRINTABLE_STRING); |
| } |
| attributeTypeAndValue.MessageEnd(); |
| } |
| |
| } |