blob: 5862faaf4ecc4c829c3e56b952f9e684888d9fdc [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)
Jeff Thompson10ad12a2013-09-24 16:19:11 -070025 signatureStruct.digestAlgorithm = (uint8_t *)digestAlgorithm_.buf();
Jeff Thompson20af0732013-09-12 17:01:45 -070026 else
27 signatureStruct.digestAlgorithm = 0;
28
29 signatureStruct.witnessLength = witness_.size();
30 if (witness_.size() > 0)
Jeff Thompson10ad12a2013-09-24 16:19:11 -070031 signatureStruct.witness = (uint8_t *)witness_.buf();
Jeff Thompson20af0732013-09-12 17:01:45 -070032 else
33 signatureStruct.witness = 0;
34
35 signatureStruct.signatureLength = signature_.size();
36 if (signature_.size() > 0)
Jeff Thompson10ad12a2013-09-24 16:19:11 -070037 signatureStruct.signature = (uint8_t *)signature_.buf();
Jeff Thompson20af0732013-09-12 17:01:45 -070038 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}