Panda3D
|
00001 // Filename: prcKeyRegistry.h 00002 // Created by: drose (19Oct04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PRCKEYREGISTRY_H 00016 #define PRCKEYREGISTRY_H 00017 00018 #include "dtoolbase.h" 00019 00020 // This file requires OpenSSL to compile, because we use routines in 00021 // the OpenSSL library to manage keys and to sign and validate 00022 // signatures. 00023 00024 #ifdef HAVE_OPENSSL 00025 00026 #include <vector> 00027 #include "openssl/evp.h" 00028 00029 // Some versions of OpenSSL appear to define this as a macro. Yucky. 00030 #undef set_key 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Class : PrcKeyRegistry 00034 // Description : This class records the set of public keys used to 00035 // verify the signature on a prc file. The actual 00036 // public keys themselves are generated by the 00037 // make-prc-key utility; the output of this utility is a 00038 // .cxx file which should be named by the 00039 // PRC_PUBLIC_KEYS_FILENAME variable in Config.pp. 00040 // 00041 // This class requires the OpenSSL library. 00042 //////////////////////////////////////////////////////////////////// 00043 class EXPCL_DTOOLCONFIG PrcKeyRegistry { 00044 protected: 00045 PrcKeyRegistry(); 00046 ~PrcKeyRegistry(); 00047 00048 public: 00049 struct KeyDef { 00050 const char *_data; 00051 size_t _length; 00052 time_t _generated_time; 00053 }; 00054 00055 void record_keys(const KeyDef *key_def, int num_keys); 00056 void set_key(int n, EVP_PKEY *pkey, time_t generated_time); 00057 00058 int get_num_keys() const; 00059 EVP_PKEY *get_key(int n) const; 00060 time_t get_generated_time(int n) const; 00061 00062 static PrcKeyRegistry *get_global_ptr(); 00063 00064 private: 00065 00066 class Key { 00067 public: 00068 const KeyDef *_def; 00069 EVP_PKEY *_pkey; 00070 time_t _generated_time; 00071 }; 00072 00073 typedef vector<Key> Keys; 00074 Keys _keys; 00075 00076 static PrcKeyRegistry *_global_ptr; 00077 }; 00078 00079 #include "prcKeyRegistry.I" 00080 00081 #endif // HAVE_OPENSSL 00082 00083 #endif 00084 00085 00086 00087 00088