blob: c2c933fb1169a750a71730d2533fa52d79d2f1cc [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;
Jeff Thompsond4144fe2013-09-18 15:59:57 -070010using namespace ndn::ptr_lib;
Jeff Thompson20af0732013-09-12 17:01:45 -070011
12namespace ndn {
13
Jeff Thompsond4144fe2013-09-18 15:59:57 -070014shared_ptr<Signature>
Jeff Thompson0050abe2013-09-17 12:50:25 -070015Sha256WithRsaSignature::clone() const
Jeff Thompson20af0732013-09-12 17:01:45 -070016{
Jeff Thompsond4144fe2013-09-18 15:59:57 -070017 return shared_ptr<Signature>(new Sha256WithRsaSignature(*this));
Jeff Thompson20af0732013-09-12 17:01:45 -070018}
19
Jeff Thompson0050abe2013-09-17 12:50:25 -070020void
21Sha256WithRsaSignature::get(struct ndn_Signature& signatureStruct) const
Jeff Thompson20af0732013-09-12 17:01:45 -070022{
23 signatureStruct.digestAlgorithmLength = digestAlgorithm_.size();
24 if (digestAlgorithm_.size() > 0)
25 signatureStruct.digestAlgorithm = (unsigned char *)digestAlgorithm_.buf();
26 else
27 signatureStruct.digestAlgorithm = 0;
28
29 signatureStruct.witnessLength = witness_.size();
30 if (witness_.size() > 0)
31 signatureStruct.witness = (unsigned char *)witness_.buf();
32 else
33 signatureStruct.witness = 0;
34
35 signatureStruct.signatureLength = signature_.size();
36 if (signature_.size() > 0)
37 signatureStruct.signature = (unsigned char *)signature_.buf();
38 else
39 signatureStruct.signature = 0;
40
41 publisherPublicKeyDigest_.get(signatureStruct.publisherPublicKeyDigest);
42 keyLocator_.get(signatureStruct.keyLocator);
43}
44
Jeff Thompson0050abe2013-09-17 12:50:25 -070045void
46Sha256WithRsaSignature::set(const struct ndn_Signature& signatureStruct)
Jeff Thompson20af0732013-09-12 17:01:45 -070047{
48 digestAlgorithm_ = Blob(signatureStruct.digestAlgorithm, signatureStruct.digestAlgorithmLength);
49 witness_ = Blob(signatureStruct.witness, signatureStruct.witnessLength);
50 signature_ = Blob(signatureStruct.signature, signatureStruct.signatureLength);
51 publisherPublicKeyDigest_.set(signatureStruct.publisherPublicKeyDigest);
52 keyLocator_.set(signatureStruct.keyLocator);
53}
54
55}