public-key.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_PUBLIC_KEY_HPP
24 #define NDN_PUBLIC_KEY_HPP
25 
26 #include "../../util/blob.hpp"
27 #include "../../encoding/oid.hpp"
28 #include "../security-common.hpp"
29 
30 namespace ndn {
31 
32 class DerNode;
33 
34 class PublicKey {
35 public:
40  : keyType_((KeyType)-1)
41  {}
42 
49  PublicKey(const Blob& keyDer);
50 
55  ptr_lib::shared_ptr<DerNode>
56  toDer();
57 
58  KeyType getKeyType() const { return keyType_; }
59 
60  /*
61  * Get the digest of the public key.
62  * @param digestAlgorithm The digest algorithm. If omitted, use DIGEST_ALGORITHM_SHA256 by default.
63  */
64  Blob
65  getDigest(DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256) const;
66 
67  /*
68  * Get the raw bytes of the public key in DER format.
69  */
70  const Blob&
71  getKeyDer() const { return keyDer_; }
72 
73 private:
74  KeyType keyType_;
75  Blob keyDer_;
76 };
77 
78 }
79 
80 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
ptr_lib::shared_ptr< DerNode > toDer()
Encode the public key into DER.
Definition: public-key.cpp:88
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
Definition: public-key.hpp:34
PublicKey()
The default constructor.
Definition: public-key.hpp:39