Panda3D
prcKeyRegistry.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file prcKeyRegistry.h
10  * @author drose
11  * @date 2004-10-19
12  */
13 
14 #ifndef PRCKEYREGISTRY_H
15 #define PRCKEYREGISTRY_H
16 
17 #include "dtoolbase.h"
18 
19 // This file requires OpenSSL to compile, because we use routines in the
20 // OpenSSL library to manage keys and to sign and validate signatures.
21 
22 #ifdef HAVE_OPENSSL
23 
24 #include <vector>
25 
26 typedef struct evp_pkey_st EVP_PKEY;
27 
28 /**
29  * This class records the set of public keys used to verify the signature on a
30  * prc file. The actual public keys themselves are generated by the make-prc-
31  * key utility; the output of this utility is a .cxx file which should be
32  * named by the PRC_PUBLIC_KEYS_FILENAME variable in Config.pp.
33  *
34  * This class requires the OpenSSL library.
35  */
36 class EXPCL_DTOOL_PRC PrcKeyRegistry {
37 protected:
38  PrcKeyRegistry();
39  ~PrcKeyRegistry();
40 
41 public:
42  struct KeyDef {
43  const char *_data;
44  size_t _length;
45  time_t _generated_time;
46  };
47 
48  void record_keys(const KeyDef *key_def, size_t num_keys);
49  void set_key(size_t n, EVP_PKEY *pkey, time_t generated_time);
50 
51  size_t get_num_keys() const;
52  EVP_PKEY *get_key(size_t n) const;
53  time_t get_generated_time(size_t n) const;
54 
55  static PrcKeyRegistry *get_global_ptr();
56 
57 private:
58 
59  class Key {
60  public:
61  const KeyDef *_def;
62  EVP_PKEY *_pkey;
63  time_t _generated_time;
64  };
65 
66  typedef std::vector<Key> Keys;
67  Keys _keys;
68 
69  static PrcKeyRegistry *_global_ptr;
70 };
71 
72 #include "prcKeyRegistry.I"
73 
74 #endif // HAVE_OPENSSL
75 
76 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.