-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsn1TBSCertificate.cpp
74 lines (60 loc) · 2.11 KB
/
Asn1TBSCertificate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Asn1TBSCertificate.cpp
*
* Created on: Nov 20, 2015
* Author: nissassin17
*/
#include "Asn1TBSCertificate.h"
#include "Util.hpp"
namespace asn1 {
Asn1TBSCertificate::Asn1TBSCertificate(ASN1 const& asn1) {
ASN1::SequenceType const& seq = asn1.getSequenceVal();
version = static_cast<int>(Util::vectorToInt(seq[0]->getIntVal()));
serialNumber.reset(new Asn1CertificateSerialNumber(*(seq[1])));
signature.reset(new Asn1AlgorithmIdentifier(*(seq[2])));
issuer.reset(new Asn1Name(*(seq[3])));
validity.reset(new Asn1Validity(*(seq[4])));
subject.reset(new Asn1Name(*(seq[5])));
subjectPublicKeyInfo.reset(new Asn1SubjectPublicKeyInfo(*(seq[6])));
}
const shared_ptr<const Asn1Name>& Asn1TBSCertificate::getIssuer() const {
return issuer;
}
const shared_ptr<const Asn1CertificateSerialNumber>& Asn1TBSCertificate::getSerialNumber() const {
return serialNumber;
}
const shared_ptr<const Asn1AlgorithmIdentifier>& Asn1TBSCertificate::getSignature() const {
return signature;
}
const shared_ptr<const Asn1Name>& Asn1TBSCertificate::getSubject() const {
return subject;
}
const shared_ptr<const Asn1SubjectPublicKeyInfo>& Asn1TBSCertificate::getSubjectPublicKeyInfo() const {
return subjectPublicKeyInfo;
}
const shared_ptr<const Asn1Validity>& Asn1TBSCertificate::getValidity() const {
return validity;
}
int Asn1TBSCertificate::getVersion() const {
return version;
}
vector<string> Asn1TBSCertificate::getIssuerList() const {
vector<shared_ptr<Asn1RelativeDistinguishedName> > seq =
issuer->getRdnSequence();
vector<string> ret;
for (vector<shared_ptr<Asn1RelativeDistinguishedName> >::const_iterator it =
seq.begin(); it != seq.end(); it++) {
for (map<ASN1::ObjectIdentifierType, shared_ptr<ASN1> >::const_iterator pair =
(*it)->getData().begin(); pair != (*it)->getData().end();
pair++) {
string identifierName = "";
for (ASN1::ObjectIdentifierType::const_iterator t =
pair->first.begin(); t != pair->first.end(); t++)
identifierName += to_string(*t);
//TODO: get string value here from PrintableString
//pair->second->getStringValue();
}
}
return ret;
}
} /* namespace asn1 */