blob: e15bbf2f70459d102928dca149c5930e11b9e576 [file] [log] [blame]
Jeff Thompson20af0732013-09-12 17:01:45 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
4 */
5
6#include "sha256-with-rsa-signature.hpp"
7
8using namespace std;
9
10namespace ndn {
11
12ptr_lib::shared_ptr<Signature> Sha256WithRsaSignature::clone() const
13{
14 return ptr_lib::shared_ptr<Signature>(new Sha256WithRsaSignature(*this));
15}
16
17void Sha256WithRsaSignature::get(struct ndn_Signature& signatureStruct) const
18{
19 signatureStruct.digestAlgorithmLength = digestAlgorithm_.size();
20 if (digestAlgorithm_.size() > 0)
21 signatureStruct.digestAlgorithm = (unsigned char *)digestAlgorithm_.buf();
22 else
23 signatureStruct.digestAlgorithm = 0;
24
25 signatureStruct.witnessLength = witness_.size();
26 if (witness_.size() > 0)
27 signatureStruct.witness = (unsigned char *)witness_.buf();
28 else
29 signatureStruct.witness = 0;
30
31 signatureStruct.signatureLength = signature_.size();
32 if (signature_.size() > 0)
33 signatureStruct.signature = (unsigned char *)signature_.buf();
34 else
35 signatureStruct.signature = 0;
36
37 publisherPublicKeyDigest_.get(signatureStruct.publisherPublicKeyDigest);
38 keyLocator_.get(signatureStruct.keyLocator);
39}
40
41void Sha256WithRsaSignature::set(const struct ndn_Signature& signatureStruct)
42{
43 digestAlgorithm_ = Blob(signatureStruct.digestAlgorithm, signatureStruct.digestAlgorithmLength);
44 witness_ = Blob(signatureStruct.witness, signatureStruct.witnessLength);
45 signature_ = Blob(signatureStruct.signature, signatureStruct.signatureLength);
46 publisherPublicKeyDigest_.set(signatureStruct.publisherPublicKeyDigest);
47 keyLocator_.set(signatureStruct.keyLocator);
48}
49
50}