23 #ifndef NDN_PRIVATE_KEY_STORAGE_HPP
24 #define NDN_PRIVATE_KEY_STORAGE_HPP
27 #include "../../encoding/oid.hpp"
28 #include "../../util/blob.hpp"
29 #include "../certificate/public-key.hpp"
30 #include "../security-common.hpp"
31 #include "../key-params.hpp"
32 #include "../../name.hpp"
68 virtual ptr_lib::shared_ptr<PublicKey>
80 sign(
const uint8_t *data,
size_t dataLength,
const Name& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256) = 0;
83 sign(
const Blob& data,
const Name& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256)
85 return sign(data.
buf(), data.
size(), keyName, digestAlgorithm);
97 decrypt(
const Name& keyName,
const uint8_t* data,
size_t dataLength,
bool isSymmetric =
false) = 0;
100 decrypt(
const Name& keyName,
const Blob& data,
bool isSymmetric =
false)
102 return decrypt(keyName, data.buf(), data.size(), isSymmetric);
114 encrypt(
const Name& keyName,
const uint8_t* data,
size_t dataLength,
bool isSymmetric =
false) = 0;
117 encrypt(
const Name& keyName,
const Blob& data,
bool isSymmetric =
false)
119 return encrypt(keyName, data.buf(), data.size(), isSymmetric);
128 generateKey(
const Name& keyName,
const KeyParams& params) = 0;
137 doesKeyExist(
const Name& keyName, KeyClass keyClass) = 0;
150 (
const std::vector<uint8_t>& privateKeyDer,
const OID& oid,
151 const ptr_lib::shared_ptr<DerNode>& parameters);
163 (
const OID& oid,
const ptr_lib::shared_ptr<DerNode>& parameters,
164 const ptr_lib::shared_ptr<DerNode>& bitString);
178 (
const ptr_lib::shared_ptr<DerNode>& algorithmParameters,
179 const Blob& privateKeyDer);
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
virtual Blob sign(const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm=DIGEST_ALGORITHM_SHA256)=0
Fetch the private key for keyName and sign the data, returning a signature Blob.
static Blob encodeSubjectPublicKeyInfo(const OID &oid, const ptr_lib::shared_ptr< DerNode > ¶meters, const ptr_lib::shared_ptr< DerNode > &bitString)
Encode the bitString into a SubjectPublicKeyInfo.
Definition: private-key-storage.cpp:56
static ec_key_st * decodeEcPrivateKey(const ptr_lib::shared_ptr< DerNode > &algorithmParameters, const Blob &privateKeyDer)
Create an EC key using the curve in the algorithmParameters, decode the privateKeyDer and set the pri...
virtual void deleteKeyPair(const Name &keyName)=0
Delete a pair of asymmetric keys.
static Blob encodePkcs8PrivateKey(const std::vector< uint8_t > &privateKeyDer, const OID &oid, const ptr_lib::shared_ptr< DerNode > ¶meters)
Encode the private key to a PKCS #8 private key.
Definition: private-key-storage.cpp:38
virtual void generateKeyPair(const Name &keyName, const KeyParams ¶ms)=0
Generate a pair of asymmetric keys.
virtual Blob encrypt(const Name &keyName, const uint8_t *data, size_t dataLength, bool isSymmetric=false)=0
Encrypt data.
virtual void generateKey(const Name &keyName, const KeyParams ¶ms)=0
Generate a symmetric key.
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
virtual Blob decrypt(const Name &keyName, const uint8_t *data, size_t dataLength, bool isSymmetric=false)=0
Decrypt data.
virtual ~PrivateKeyStorage()
The virtual destructor.
Definition: private-key-storage.hpp:46
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
const uint8_t * buf() const
Return a const pointer to the first byte of the immutable byte array, or 0 if the pointer is null...
Definition: blob.hpp:159
size_t size() const
Return the length of the immutable byte array.
Definition: blob.hpp:147
KeyParams is a base class for key parameters.
Definition: key-params.hpp:34
virtual ptr_lib::shared_ptr< PublicKey > getPublicKey(const Name &keyName)=0
Get the public key.
virtual bool doesKeyExist(const Name &keyName, KeyClass keyClass)=0
Check if a particular key exists.
Definition: private-key-storage.hpp:40