00001 /* 00002 * Copyright 2003-2004 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 #include <axutil_utils_defines.h> 00018 /* 00019 * @file axutil_base64.h 00020 * @brief AXIS2-UTIL Base64 Encoding 00021 */ 00022 #ifndef AXUTIL_BASE64_H 00023 #define AXUTIL_BASE64_H 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 /* 00030 * @defgroup AXIS2_Util_Base64 base64 encoding 00031 * @ingroup AXIS2_Util 00032 */ 00033 00034 /* Simple BASE64 encode/decode functions. 00035 * 00036 * As we might encode binary strings, hence we require the length of 00037 * the incoming plain source. And return the length of what we decoded. 00038 * 00039 * The decoding function takes any non valid char (i.e. whitespace, \0 00040 * or anything non A-Z,0-9 etc as terminal. 00041 * 00042 * plain strings/binary sequences are not assumed '\0' terminated. Encoded 00043 * strings are neither. But probably should. 00044 * 00045 */ 00046 00047 /* 00048 * Given the length of an un-encrypted string, get the length of the 00049 * encrypted string. 00050 * @param len the length of an unencrypted string. 00051 * @return the length of the string after it is encrypted 00052 */ 00053 AXIS2_EXTERN int AXIS2_CALL axutil_base64_encode_len(int len); 00054 00055 /* 00056 * Encode a text string using base64encoding. 00057 * @param coded_dst The destination string for the encoded string. 00058 * @param plain_src The original string in plain text 00059 * @param len_plain_src The length of the plain text string 00060 * @return the length of the encoded string 00061 */ 00062 AXIS2_EXTERN int AXIS2_CALL axutil_base64_encode(char * coded_dst, const char *plain_src, 00063 int len_plain_src); 00064 00065 /* 00066 * Encode an EBCDIC string using base64encoding. 00067 * @param coded_dst The destination string for the encoded string. 00068 * @param plain_src The original string in plain text 00069 * @param len_plain_src The length of the plain text string 00070 * @return the length of the encoded string 00071 */ 00072 AXIS2_EXTERN int AXIS2_CALL axutil_base64_encode_binary(char * coded_dst, 00073 const unsigned char *plain_src, 00074 int len_plain_src); 00075 00076 /* 00077 * Determine the length of a plain text string given the encoded version 00078 * @param coded_src The encoded string 00079 * @return the length of the plain text string 00080 */ 00081 AXIS2_EXTERN int AXIS2_CALL axutil_base64_decode_len(const char * coded_src); 00082 00083 /* 00084 * Decode a string to plain text 00085 * @param plain_dst The destination string for the plain text 00086 * @param coded_src The encoded string 00087 * @return the length of the plain text string 00088 */ 00089 AXIS2_EXTERN int AXIS2_CALL axutil_base64_decode(char * plain_dst, const char *coded_src); 00090 00091 /* 00092 * Decode an EBCDIC string to plain text 00093 * @param plain_dst The destination string for the plain text 00094 * @param coded_src The encoded string 00095 * @return the length of the plain text string 00096 */ 00097 AXIS2_EXTERN int AXIS2_CALL axutil_base64_decode_binary(unsigned char * plain_dst, 00098 const char *coded_src); 00099 00100 /* @} */ 00101 #ifdef __cplusplus 00102 } 00103 #endif 00104 00105 #endif /* !AXIS2_BASE64_H */