aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey
diff options
context:
space:
mode:
Diffstat (limited to 'src/pubkey')
-rw-r--r--src/pubkey/ec_dompar/ec_dompar.cpp2
-rw-r--r--src/pubkey/ec_dompar/ec_dompar.h2
-rw-r--r--src/pubkey/pubkey/info.txt2
-rw-r--r--src/pubkey/pubkey/pkcs8.h1
-rw-r--r--src/pubkey/pubkey/pubkey_enums.cpp40
-rw-r--r--src/pubkey/pubkey/pubkey_enums.h75
-rw-r--r--src/pubkey/pubkey/x509_key.h2
7 files changed, 120 insertions, 4 deletions
diff --git a/src/pubkey/ec_dompar/ec_dompar.cpp b/src/pubkey/ec_dompar/ec_dompar.cpp
index cf6ef8fab..88a1c71e2 100644
--- a/src/pubkey/ec_dompar/ec_dompar.cpp
+++ b/src/pubkey/ec_dompar/ec_dompar.cpp
@@ -1,6 +1,6 @@
#include <botan/ec_dompar.h>
-#include <botan/enums.h>
+#include <botan/pubkey_enums.h>
#include <botan/parsing.h>
#include <botan/libstate.h>
#include <botan/hex.h>
diff --git a/src/pubkey/ec_dompar/ec_dompar.h b/src/pubkey/ec_dompar/ec_dompar.h
index bda19ec86..9abfafdb4 100644
--- a/src/pubkey/ec_dompar/ec_dompar.h
+++ b/src/pubkey/ec_dompar/ec_dompar.h
@@ -14,7 +14,7 @@
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/alg_id.h>
-#include <botan/enums.h>
+#include <botan/pubkey_enums.h>
namespace Botan {
diff --git a/src/pubkey/pubkey/info.txt b/src/pubkey/pubkey/info.txt
index 9a8766790..71d56e17e 100644
--- a/src/pubkey/pubkey/info.txt
+++ b/src/pubkey/pubkey/info.txt
@@ -15,6 +15,8 @@ rng
</requires>
<add>
+pubkey_enums.h
+pubkey_enums.cpp
pk_keys.cpp
pk_keys.h
pkcs8.cpp
diff --git a/src/pubkey/pubkey/pkcs8.h b/src/pubkey/pubkey/pkcs8.h
index 0598e7c68..863a80b86 100644
--- a/src/pubkey/pubkey/pkcs8.h
+++ b/src/pubkey/pubkey/pkcs8.h
@@ -8,7 +8,6 @@
#include <botan/x509_key.h>
#include <botan/ui.h>
-#include <botan/enums.h>
namespace Botan {
diff --git a/src/pubkey/pubkey/pubkey_enums.cpp b/src/pubkey/pubkey/pubkey_enums.cpp
new file mode 100644
index 000000000..fd230d6f4
--- /dev/null
+++ b/src/pubkey/pubkey/pubkey_enums.cpp
@@ -0,0 +1,40 @@
+/*************************************************
+* KeyUsage Source File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#include <botan/pubkey_enums.h>
+#include <botan/ber_dec.h>
+
+namespace Botan {
+
+namespace BER {
+
+/*************************************************
+* Decode a BER encoded KeyUsage *
+*************************************************/
+void decode(BER_Decoder& source, Key_Constraints& key_usage)
+ {
+ BER_Object obj = source.get_next_object();
+
+ if(obj.type_tag != BIT_STRING || obj.class_tag != UNIVERSAL)
+ throw BER_Bad_Tag("Bad tag for usage constraint",
+ obj.type_tag, obj.class_tag);
+ if(obj.value.size() != 2 && obj.value.size() != 3)
+ throw BER_Decoding_Error("Bad size for BITSTRING in usage constraint");
+ if(obj.value[0] >= 8)
+ throw BER_Decoding_Error("Invalid unused bits in usage constraint");
+
+ const byte mask = (0xFF << obj.value[0]);
+ obj.value[obj.value.size()-1] &= mask;
+
+ u16bit usage = 0;
+ for(u32bit j = 1; j != obj.value.size(); ++j)
+ usage = (obj.value[j] << 8) | usage;
+
+ key_usage = Key_Constraints(usage);
+ }
+
+}
+
+}
diff --git a/src/pubkey/pubkey/pubkey_enums.h b/src/pubkey/pubkey/pubkey_enums.h
new file mode 100644
index 000000000..eaed24921
--- /dev/null
+++ b/src/pubkey/pubkey/pubkey_enums.h
@@ -0,0 +1,75 @@
+/*************************************************
+* Enumerations Header File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#ifndef BOTAN_ENUMS_H__
+#define BOTAN_ENUMS_H__
+
+#include <botan/ber_dec.h>
+
+namespace Botan {
+
+/**
+* X.509v3 Key Constraints.
+*/
+enum Key_Constraints {
+ NO_CONSTRAINTS = 0,
+ DIGITAL_SIGNATURE = 32768,
+ NON_REPUDIATION = 16384,
+ KEY_ENCIPHERMENT = 8192,
+ DATA_ENCIPHERMENT = 4096,
+ KEY_AGREEMENT = 2048,
+ KEY_CERT_SIGN = 1024,
+ CRL_SIGN = 512,
+ ENCIPHER_ONLY = 256,
+ DECIPHER_ONLY = 128
+};
+
+/**
+* BER Decoding Function for key constraints
+*/
+namespace BER {
+
+void BOTAN_DLL decode(BER_Decoder&, Key_Constraints&);
+
+}
+
+/**
+* X.509v2 CRL Reason Code.
+*/
+enum CRL_Code {
+ UNSPECIFIED = 0,
+ KEY_COMPROMISE = 1,
+ CA_COMPROMISE = 2,
+ AFFILIATION_CHANGED = 3,
+ SUPERSEDED = 4,
+ CESSATION_OF_OPERATION = 5,
+ CERTIFICATE_HOLD = 6,
+ REMOVE_FROM_CRL = 8,
+ PRIVLEDGE_WITHDRAWN = 9,
+ AA_COMPROMISE = 10,
+
+ DELETE_CRL_ENTRY = 0xFF00,
+ OCSP_GOOD = 0xFF01,
+ OCSP_UNKNOWN = 0xFF02
+};
+
+/*************************************************
+* Various Other Enumerations *
+*************************************************/
+
+/**
+* The two types of X509 encoding supported by Botan.
+*/
+enum X509_Encoding { RAW_BER, PEM };
+
+/**
+* Value to encode in case of no path limit in the X509
+* BasicConstraints extension.
+*/
+static const u32bit NO_CERT_PATH_LIMIT = 0xFFFFFFF0;
+
+}
+
+#endif
diff --git a/src/pubkey/pubkey/x509_key.h b/src/pubkey/pubkey/x509_key.h
index b407342e6..b60a3af05 100644
--- a/src/pubkey/pubkey/x509_key.h
+++ b/src/pubkey/pubkey/x509_key.h
@@ -9,7 +9,7 @@
#include <botan/pipe.h>
#include <botan/pk_keys.h>
#include <botan/alg_id.h>
-#include <botan/enums.h>
+#include <botan/pubkey_enums.h>
namespace Botan {