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; |
| 10 | |
| 11 | namespace ndn { |
| 12 | |
| 13 | ptr_lib::shared_ptr<Signature> Sha256WithRsaSignature::clone() const |
| 14 | { |
| 15 | return ptr_lib::shared_ptr<Signature>(new Sha256WithRsaSignature(*this)); |
| 16 | } |
| 17 | |
| 18 | void 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 | |
| 42 | void 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 | } |