00001 /* 00002 * Copyright 2002-2005 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /* 00018 * XSEC 00019 * 00020 * XSECCryptoUtils:= Helper crypo utilities that make life easier 00021 * 00022 * Author(s): Berin Lautenbach 00023 * 00024 * $Id: XSECCryptoUtils.hpp,v 1.4 2005/06/10 07:59:21 blautenb Exp $ 00025 * 00026 */ 00027 00028 #ifndef XSECCRYPTOUTILS_INCLUDE 00029 #define XSECCRYPTOUTILS_INCLUDE 00030 00031 #include <xsec/framework/XSECDefs.hpp> 00032 #include <xsec/utils/XSECSafeBuffer.hpp> 00033 00039 // -------------------------------------------------------------------------------- 00040 // XKMS Limited-Use Shared Secret handling 00041 // -------------------------------------------------------------------------------- 00042 00043 #define XKMSAuthenticationValue 0x01 00044 #define XKMSRevocationCodeIdenfitierEncoding1 0x02 00045 #define XKMSRevocationCodeIdenfitierEncoding2 0x03 00046 #define XKMSKeyEncryption 0x04 00047 00048 int DSIG_EXPORT CalculateXKMSAuthenticationKey(unsigned char * input, int inputLen, unsigned char * output, int maxOutputLen); 00049 int DSIG_EXPORT CalculateXKMSRevocationCodeIdentifierEncoding1(unsigned char * input, int inputLen, unsigned char * output, int maxOutputLen); 00050 /* Calculate encoding 2 - Input is original pass phrase */ 00051 int DSIG_EXPORT CalculateXKMSRevocationCodeIdentifierEncoding2(unsigned char * input, int inputLen, unsigned char * output, int maxOutputLen); 00052 /* Calculate encoding 2 - Input is encoding 1 */ 00053 int DSIG_EXPORT CalculateXKMSRevocationCodeIdentifierEncoding2From1(unsigned char * input, int inputLen, unsigned char * output, int maxOutputLen); 00054 int DSIG_EXPORT CalculateXKMSKEK(unsigned char * input, int inputLen, unsigned char * output, int maxOutputLen); 00055 00056 // -------------------------------------------------------------------------------- 00057 // Some Base64 helpers 00058 // -------------------------------------------------------------------------------- 00059 00060 XMLCh DSIG_EXPORT * EncodeToBase64XMLCh(unsigned char * input, int inputLen); 00061 00062 // -------------------------------------------------------------------------------- 00063 // Some stuff to help with wierd signatures 00064 // -------------------------------------------------------------------------------- 00065 00066 // Convert an ASN.1 format DSA signature (!!!) to the two component integers 00067 // NOTE - both r and s must be at least 20 bytes long 00068 00069 bool DSIG_EXPORT ASN2DSASig(const unsigned char * input, unsigned char * r, unsigned char * s); 00070 00071 #endif /* XSECCRYPTOUTILS_INCLUDE */ 00072 00073