blob: aad9c9fe138f3a612a31ea13b79fef6cde65b13c [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
Jeff Thompson0050abe2013-09-17 12:50:25 -070013ptr_lib::shared_ptr<Signature>
14Sha256WithRsaSignature::clone() const
Jeff Thompson20af0732013-09-12 17:01:45 -070015{
16 return ptr_lib::shared_ptr<Signature>(new Sha256WithRsaSignature(*this));
17}
18
Jeff Thompson0050abe2013-09-17 12:50:25 -070019void
20Sha256WithRsaSignature::get(struct ndn_Signature& signatureStruct) const
Jeff Thompson20af0732013-09-12 17:01:45 -070021{
22 signatureStruct.digestAlgorithmLength = digestAlgorithm_.size();
23 if (digestAlgorithm_.size() > 0)
24 signatureStruct.digestAlgorithm = (unsigned char *)digestAlgorithm_.buf();
25 else
26 signatureStruct.digestAlgorithm = 0;
27
28 signatureStruct.witnessLength = witness_.size();
29 if (witness_.size() > 0)
30 signatureStruct.witness = (unsigned char *)witness_.buf();
31 else
32 signatureStruct.witness = 0;
33
34 signatureStruct.signatureLength = signature_.size();
35 if (signature_.size() > 0)
36 signatureStruct.signature = (unsigned char *)signature_.buf();
37 else
38 signatureStruct.signature = 0;
39
40 publisherPublicKeyDigest_.get(signatureStruct.publisherPublicKeyDigest);
41 keyLocator_.get(signatureStruct.keyLocator);
42}
43
Jeff Thompson0050abe2013-09-17 12:50:25 -070044void
45Sha256WithRsaSignature::set(const struct ndn_Signature& signatureStruct)
Jeff Thompson20af0732013-09-12 17:01:45 -070046{
47 digestAlgorithm_ = Blob(signatureStruct.digestAlgorithm, signatureStruct.digestAlgorithmLength);
48 witness_ = Blob(signatureStruct.witness, signatureStruct.witnessLength);
49 signature_ = Blob(signatureStruct.signature, signatureStruct.signatureLength);
50 publisherPublicKeyDigest_.set(signatureStruct.publisherPublicKeyDigest);
51 keyLocator_.set(signatureStruct.keyLocator);
52}
53
54}