Add helpers to encode keys into DER.
[shibboleth/cpp-xmltooling.git] / xmltooling / security / SecurityHelper.h
index 4c0bbf9..b62bdf5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2008 Internet2
+ *  Copyright 2001-2009 Internet2
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,6 +38,14 @@ namespace xmltooling {
     {
     public:
         /**
+         * Access a file to try and guess the encoding format used.
+         *
+         * @param pathname  path to file
+         * @return  constant identifying encoding format
+         */
+        static const char* guessEncodingFormat(const char* pathname);
+
+        /**
          * Loads a private key from a local file.
          *
          * @param pathname  path to file containing key
@@ -116,6 +124,22 @@ namespace xmltooling {
          * @return  true iff the keys match
          */
         static bool matches(const XSECCryptoKey* key1, const XSECCryptoKey* key2);
+
+        /**
+         * Returns the base64-encoded DER encoding of a public key in SubjectPublicKeyInfo format.
+         *
+         * @param key   the key to encode
+         * @return  the base64 encoded key value
+         */
+        static std::string getDEREncoding(const XSECCryptoKey* key);
+
+        /**
+         * Returns the base64-encoded DER encoding of a certifiate's public key in SubjectPublicKeyInfo format.
+         *
+         * @param cert   the certificate's key to encode
+         * @return  the base64 encoded key value
+         */
+        static std::string getDEREncoding(const XSECCryptoX509* cert);
     };
 };