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