Jeff Thompson | fa30664 | 2013-06-17 15:06:57 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013, Regents of the University of California |
| 4 | * Alexander Afanasyev |
| 5 | * |
| 6 | * BSD license, See the LICENSE file for more information |
| 7 | * |
| 8 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 9 | */ |
| 10 | |
| 11 | #ifndef NDN_KEYCHAIN_PKCS12_H |
| 12 | #define NDN_KEYCHAIN_PKCS12_H |
| 13 | |
| 14 | #include "keychain.h" |
| 15 | #include "ndn-cpp/helpers/hash.h" |
| 16 | |
| 17 | namespace ndn |
| 18 | { |
| 19 | |
| 20 | /** |
| 21 | * @brief Class implementing logic to work with pkcs12 CCNx keystore file (.ccnx_keystore) |
| 22 | */ |
| 23 | class KeychainKeystoreOpenssl : public virtual Keychain |
| 24 | { |
| 25 | public: |
| 26 | KeychainKeystoreOpenssl (); |
| 27 | KeychainKeystoreOpenssl (const std::string &path); |
| 28 | |
| 29 | public: |
| 30 | ///////////////////////////////////////////////////// |
| 31 | // interface to manage certificates and identities // |
| 32 | ///////////////////////////////////////////////////// |
| 33 | |
| 34 | virtual Ptr<const Identity> |
| 35 | getDefaultIdentity (); |
| 36 | |
| 37 | virtual Ptr<const Identity> |
| 38 | getIdentity (const Name &identityName); |
| 39 | |
| 40 | virtual Ptr<const Identity> |
| 41 | generateIdentity (const Name &identityName); |
| 42 | |
| 43 | virtual void |
| 44 | requestIdentityCertificate (const Identity &identity, std::ostream &os); |
| 45 | |
| 46 | virtual Ptr<const Certificate> |
| 47 | issueCertificate (const Identity &identity, std::istream &is); |
| 48 | |
| 49 | virtual Ptr<const Certificate> |
| 50 | issueCertificate (std::istream &is); |
| 51 | |
| 52 | virtual void |
| 53 | installIdentityCertificate (const Certificate &cert); |
| 54 | |
| 55 | public: |
| 56 | ///////////////////////////////////////////////////// |
| 57 | // interface to sign and encrypt data // |
| 58 | ///////////////////////////////////////////////////// |
| 59 | virtual Ptr<Signature> |
| 60 | sign (const Identity &identity, const void *buffer, size_t size); |
| 61 | |
| 62 | |
| 63 | private: |
| 64 | void |
| 65 | initialize (const std::string &pkcs12); |
| 66 | |
| 67 | private: |
| 68 | Name m_publicKeyName; |
| 69 | Hash m_publicKeyDigest; |
| 70 | }; |
| 71 | |
| 72 | } // ndn |
| 73 | |
| 74 | #endif // NDN_KEYCHAIN_KEYSTORE_OPENSSL_H |