Set fourth file version digit to signify rebuild.
[shibboleth/cpp-xmltooling.git] / xmltooling / encryption / Encrypter.h
index 33383ad..1996b48 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  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.
- * You may obtain a copy of the License at
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
  */
 
 /**
 #if !defined(__xmltooling_encrypter_h__) && !defined(XMLTOOLING_NO_XMLSEC)
 #define __xmltooling_encrypter_h__
 
-#include <xmltooling/encryption/Encryption.h>
+#include <xmltooling/exceptions.h>
 
-#include <xsec/enc/XSECCryptoKey.hpp>
-#include <xsec/xenc/XENCCipher.hpp>
+#include <xsec/dsig/DSIGConstants.hpp>
+
+class XENCCipher;
 
 namespace xmltooling {
     class XMLTOOL_API Credential;
@@ -34,6 +39,9 @@ namespace xmltooling {
 
 namespace xmlencryption {
 
+    class XMLTOOL_API EncryptedData;
+    class XMLTOOL_API EncryptedKey;
+
     /**
      * Wrapper API for XML Encryption functionality.
      * Designed to allow both external and internal key generation as follows:
@@ -77,16 +85,18 @@ namespace xmlencryption {
              * @param compact       true iff the encrypted representation should be made as small as possible
              */
             EncryptionParams(
+#ifdef XSEC_OPENSSL_HAVE_AES
                 const XMLCh* algorithm=DSIGConstants::s_unicodeStrURIAES128_CBC,
-                const unsigned char* keyBuffer=NULL,
+#else
+                const XMLCh* algorithm=DSIGConstants::s_unicodeStrURI3DES_CBC,
+#endif
+                const unsigned char* keyBuffer=nullptr,
                 unsigned int keyBufferSize=0,
-                const xmltooling::Credential* credential=NULL,
+                const xmltooling::Credential* credential=nullptr,
                 bool compact=false
-                ) :  m_algorithm(algorithm), m_keyBuffer(keyBuffer), m_keyBufferSize(keyBufferSize),
-                    m_credential(credential), m_compact(compact) {
-            }
+                );
 
-            ~EncryptionParams() {}
+            ~EncryptionParams();
 
             /** Data encryption algorithm. */
             const XMLCh* m_algorithm;
@@ -116,13 +126,10 @@ namespace xmlencryption {
              * @param recipient     optional name of recipient of encrypted key
              */
             KeyEncryptionParams(
-                const xmltooling::Credential& credential,
-                const XMLCh* algorithm=NULL,
-                const XMLCh* recipient=NULL
-                ) : m_credential(credential), m_algorithm(algorithm), m_recipient(recipient) {
-            }
+                const xmltooling::Credential& credential, const XMLCh* algorithm=nullptr, const XMLCh* recipient=nullptr
+                );
         
-            ~KeyEncryptionParams() {}
+            ~KeyEncryptionParams();
 
             /** Credential containing key encryption key. */
             const xmltooling::Credential& m_credential;
@@ -134,7 +141,7 @@ namespace xmlencryption {
             const XMLCh* m_recipient;
         };
     
-        Encrypter() : m_cipher(NULL) {}
+        Encrypter();
 
         virtual ~Encrypter();
         
@@ -150,11 +157,11 @@ namespace xmlencryption {
          * 
          * @param element       the DOM element to encrypt
          * @param encParams     primary encryption settings
-         * @param kencParams    key encryption settings, or NULL
+         * @param kencParams    key encryption settings, or nullptr
          * @return a stand-alone EncryptedData object, unconnected to the source DOM 
          */
         EncryptedData* encryptElement(
-            xercesc::DOMElement* element, EncryptionParams& encParams, KeyEncryptionParams* kencParams=NULL
+            xercesc::DOMElement* element, EncryptionParams& encParams, KeyEncryptionParams* kencParams=nullptr
             );
 
         /**
@@ -169,11 +176,11 @@ namespace xmlencryption {
          * 
          * @param element       parent element of children to encrypt
          * @param encParams     primary encryption settings
-         * @param kencParams    key encryption settings, or NULL
+         * @param kencParams    key encryption settings, or nullptr
          * @return a stand-alone EncryptedData object, unconnected to the source DOM 
          */
         EncryptedData* encryptElementContent(
-            xercesc::DOMElement* element, EncryptionParams& encParams, KeyEncryptionParams* kencParams=NULL
+            xercesc::DOMElement* element, EncryptionParams& encParams, KeyEncryptionParams* kencParams=nullptr
             );
 
         /**
@@ -188,10 +195,10 @@ namespace xmlencryption {
          * 
          * @param input         the stream to encrypt
          * @param encParams     primary encryption settings
-         * @param kencParams    key encryption settings, or NULL
+         * @param kencParams    key encryption settings, or nullptr
          * @return a stand-alone EncryptedData object, unconnected to any DOM 
          */
-        EncryptedData* encryptStream(std::istream& input, EncryptionParams& encParams, KeyEncryptionParams* kencParams=NULL);
+        EncryptedData* encryptStream(std::istream& input, EncryptionParams& encParams, KeyEncryptionParams* kencParams=nullptr);
         
         /**
          * Encrypts the supplied key and returns the resulting object.