-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsn1SubjectPublicKeyInfo.cpp
38 lines (30 loc) · 1.05 KB
/
Asn1SubjectPublicKeyInfo.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
/*
* Asn1SubjectPublicKeyInfo.cpp
*
* Created on: Nov 20, 2015
* Author: nissassin17
*/
#include "Asn1SubjectPublicKeyInfo.h"
#include "Util.hpp"
namespace asn1 {
Asn1SubjectPublicKeyInfo::Asn1SubjectPublicKeyInfo(ASN1 const& asn1) {
ASN1::SequenceType const& seq = asn1.getSequenceVal();
algorithm.reset(new Asn1AlgorithmIdentifier(*(seq[0])));
//TODO:define type of subject public key info based on algorithm
//here we just use rsa format
subjectPublicKey = ASN1::BitStringType(seq[1]->getBitStringVal());
}
const ASN1::BitStringType& Asn1SubjectPublicKeyInfo::getSubjectPublicKey() const {
return subjectPublicKey;
}
int Asn1SubjectPublicKeyInfo::getExponent() const {
return static_cast<int>(Util::vectorToInt(
ASN1(subjectPublicKey).getSequenceVal()[1]->getIntVal()));
}
vector<uint8_t> Asn1SubjectPublicKeyInfo::getModulus() const {
return ASN1(subjectPublicKey).getSequenceVal()[0]->getIntVal();
}
const shared_ptr<Asn1AlgorithmIdentifier>& Asn1SubjectPublicKeyInfo::getAlgorithm() const {
return algorithm;
}
} /* namespace asn1 */