Jeff Thompson | 20af073 | 2013-09-12 17:01:45 -0700 | [diff] [blame] | 1 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 Regents of the University of California. |
| 3 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 20af073 | 2013-09-12 17:01:45 -0700 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "sha256-with-rsa-signature.hpp" |
| 8 | |
| 9 | using namespace std; |
Jeff Thompson | d4144fe | 2013-09-18 15:59:57 -0700 | [diff] [blame^] | 10 | using namespace ndn::ptr_lib; |
Jeff Thompson | 20af073 | 2013-09-12 17:01:45 -0700 | [diff] [blame] | 11 | |
| 12 | namespace ndn { |
| 13 | |
Jeff Thompson | d4144fe | 2013-09-18 15:59:57 -0700 | [diff] [blame^] | 14 | shared_ptr<Signature> |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 15 | Sha256WithRsaSignature::clone() const |
Jeff Thompson | 20af073 | 2013-09-12 17:01:45 -0700 | [diff] [blame] | 16 | { |
Jeff Thompson | d4144fe | 2013-09-18 15:59:57 -0700 | [diff] [blame^] | 17 | return shared_ptr<Signature>(new Sha256WithRsaSignature(*this)); |
Jeff Thompson | 20af073 | 2013-09-12 17:01:45 -0700 | [diff] [blame] | 18 | } |
| 19 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 20 | void |
| 21 | Sha256WithRsaSignature::get(struct ndn_Signature& signatureStruct) const |
Jeff Thompson | 20af073 | 2013-09-12 17:01:45 -0700 | [diff] [blame] | 22 | { |
| 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 Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 45 | void |
| 46 | Sha256WithRsaSignature::set(const struct ndn_Signature& signatureStruct) |
Jeff Thompson | 20af073 | 2013-09-12 17:01:45 -0700 | [diff] [blame] | 47 | { |
| 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 | } |