crypto_openssl.h revision 1.5.28.1
1/* $NetBSD: crypto_openssl.h,v 1.5.28.1 2009/05/13 19:15:54 jym Exp $ */ 2 3/* Id: crypto_openssl.h,v 1.11 2004/11/13 11:28:01 manubsd Exp */ 4 5/* 6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of the project nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#ifndef _CRYPTO_OPENSSL_H 35#define _CRYPTO_OPENSSL_H 36 37#include "crypto_openssl.h" 38 39#include <openssl/x509v3.h> 40#include <openssl/rsa.h> 41 42#define GENT_OTHERNAME GEN_OTHERNAME 43#define GENT_EMAIL GEN_EMAIL 44#define GENT_DNS GEN_DNS 45#define GENT_X400 GEN_X400 46#define GENT_DIRNAME GEN_DIRNAME 47#define GENT_EDIPARTY GEN_EDIPARTY 48#define GENT_URI GEN_URI 49#define GENT_IPADD GEN_IPADD 50#define GENT_RID GEN_RID 51 52extern vchar_t *eay_str2asn1dn __P((const char *, int)); 53extern vchar_t *eay_hex2asn1dn __P((const char *, int)); 54extern int eay_cmp_asn1dn __P((vchar_t *, vchar_t *)); 55extern int eay_check_x509cert __P((vchar_t *, char *, char *, int)); 56extern vchar_t *eay_get_x509asn1subjectname __P((vchar_t *)); 57extern int eay_get_x509subjectaltname __P((vchar_t *, char **, int *, int)); 58extern vchar_t * eay_get_x509asn1issuername __P((vchar_t *)); 59extern char *eay_get_x509text __P((vchar_t *)); 60extern vchar_t *eay_get_x509cert __P((char *)); 61extern vchar_t *eay_get_x509sign __P((vchar_t *, vchar_t *)); 62extern int eay_check_x509sign __P((vchar_t *, vchar_t *, vchar_t *)); 63 64extern int eay_check_rsasign __P((vchar_t *, vchar_t *, RSA *)); 65extern vchar_t *eay_get_rsasign __P((vchar_t *, RSA *)); 66 67/* RSA */ 68extern vchar_t *eay_rsa_sign __P((vchar_t *, RSA *)); 69extern int eay_rsa_verify __P((vchar_t *, vchar_t *, RSA *)); 70 71/* ASN.1 */ 72extern vchar_t *eay_get_pkcs1privkey __P((char *)); 73extern vchar_t *eay_get_pkcs1pubkey __P((char *)); 74 75/* string error */ 76extern char *eay_strerror __P((void)); 77 78/* OpenSSL initialization */ 79extern void eay_init __P((void)); 80 81/* Generic EVP */ 82extern vchar_t *evp_crypt __P((vchar_t *data, vchar_t *key, vchar_t *iv, 83 const EVP_CIPHER *e, int enc)); 84extern int evp_weakkey __P((vchar_t *key, const EVP_CIPHER *e)); 85extern int evp_keylen __P((int len, const EVP_CIPHER *e)); 86 87/* DES */ 88extern vchar_t *eay_des_encrypt __P((vchar_t *, vchar_t *, vchar_t *)); 89extern vchar_t *eay_des_decrypt __P((vchar_t *, vchar_t *, vchar_t *)); 90extern int eay_des_weakkey __P((vchar_t *)); 91extern int eay_des_keylen __P((int)); 92 93/* IDEA */ 94extern vchar_t *eay_idea_encrypt __P((vchar_t *, vchar_t *, vchar_t *)); 95extern vchar_t *eay_idea_decrypt __P((vchar_t *, vchar_t *, vchar_t *)); 96extern int eay_idea_weakkey __P((vchar_t *)); 97extern int eay_idea_keylen __P((int)); 98 99/* blowfish */ 100extern vchar_t *eay_bf_encrypt __P((vchar_t *, vchar_t *, vchar_t *)); 101extern vchar_t *eay_bf_decrypt __P((vchar_t *, vchar_t *, vchar_t *)); 102extern int eay_bf_weakkey __P((vchar_t *)); 103extern int eay_bf_keylen __P((int)); 104 105/* RC5 */ 106extern vchar_t *eay_rc5_encrypt __P((vchar_t *, vchar_t *, vchar_t *)); 107extern vchar_t *eay_rc5_decrypt __P((vchar_t *, vchar_t *, vchar_t *)); 108extern int eay_rc5_weakkey __P((vchar_t *)); 109extern int eay_rc5_keylen __P((int)); 110 111/* 3DES */ 112extern vchar_t *eay_3des_encrypt __P((vchar_t *, vchar_t *, vchar_t *)); 113extern vchar_t *eay_3des_decrypt __P((vchar_t *, vchar_t *, vchar_t *)); 114extern int eay_3des_weakkey __P((vchar_t *)); 115extern int eay_3des_keylen __P((int)); 116 117/* CAST */ 118extern vchar_t *eay_cast_encrypt __P((vchar_t *, vchar_t *, vchar_t *)); 119extern vchar_t *eay_cast_decrypt __P((vchar_t *, vchar_t *, vchar_t *)); 120extern int eay_cast_weakkey __P((vchar_t *)); 121extern int eay_cast_keylen __P((int)); 122 123/* AES(RIJNDAEL) */ 124extern vchar_t *eay_aes_encrypt __P((vchar_t *, vchar_t *, vchar_t *)); 125extern vchar_t *eay_aes_decrypt __P((vchar_t *, vchar_t *, vchar_t *)); 126extern int eay_aes_weakkey __P((vchar_t *)); 127extern int eay_aes_keylen __P((int)); 128 129#if defined(HAVE_OPENSSL_CAMELLIA_H) 130/* Camellia */ 131extern vchar_t *eay_camellia_encrypt __P((vchar_t *, vchar_t *, vchar_t *)); 132extern vchar_t *eay_camellia_decrypt __P((vchar_t *, vchar_t *, vchar_t *)); 133extern int eay_camellia_weakkey __P((vchar_t *)); 134extern int eay_camellia_keylen __P((int)); 135#endif 136 137/* misc */ 138extern int eay_null_keylen __P((int)); 139extern int eay_null_hashlen __P((void)); 140extern int eay_kpdk_hashlen __P((void)); 141extern int eay_twofish_keylen __P((int)); 142 143/* hash */ 144#if defined(WITH_SHA2) 145/* HMAC SHA2 */ 146extern vchar_t *eay_hmacsha2_512_one __P((vchar_t *, vchar_t *)); 147extern caddr_t eay_hmacsha2_512_init __P((vchar_t *)); 148extern void eay_hmacsha2_512_update __P((caddr_t, vchar_t *)); 149extern vchar_t *eay_hmacsha2_512_final __P((caddr_t)); 150extern vchar_t *eay_hmacsha2_384_one __P((vchar_t *, vchar_t *)); 151extern caddr_t eay_hmacsha2_384_init __P((vchar_t *)); 152extern void eay_hmacsha2_384_update __P((caddr_t, vchar_t *)); 153extern vchar_t *eay_hmacsha2_384_final __P((caddr_t)); 154extern vchar_t *eay_hmacsha2_256_one __P((vchar_t *, vchar_t *)); 155extern caddr_t eay_hmacsha2_256_init __P((vchar_t *)); 156extern void eay_hmacsha2_256_update __P((caddr_t, vchar_t *)); 157extern vchar_t *eay_hmacsha2_256_final __P((caddr_t)); 158#endif 159/* HMAC SHA1 */ 160extern vchar_t *eay_hmacsha1_one __P((vchar_t *, vchar_t *)); 161extern caddr_t eay_hmacsha1_init __P((vchar_t *)); 162extern void eay_hmacsha1_update __P((caddr_t, vchar_t *)); 163extern vchar_t *eay_hmacsha1_final __P((caddr_t)); 164/* HMAC MD5 */ 165extern vchar_t *eay_hmacmd5_one __P((vchar_t *, vchar_t *)); 166extern caddr_t eay_hmacmd5_init __P((vchar_t *)); 167extern void eay_hmacmd5_update __P((caddr_t, vchar_t *)); 168extern vchar_t *eay_hmacmd5_final __P((caddr_t)); 169 170#if defined(WITH_SHA2) 171/* SHA2 functions */ 172extern caddr_t eay_sha2_512_init __P((void)); 173extern void eay_sha2_512_update __P((caddr_t, vchar_t *)); 174extern vchar_t *eay_sha2_512_final __P((caddr_t)); 175extern vchar_t *eay_sha2_512_one __P((vchar_t *)); 176#endif 177extern int eay_sha2_512_hashlen __P((void)); 178 179#if defined(WITH_SHA2) 180extern caddr_t eay_sha2_384_init __P((void)); 181extern void eay_sha2_384_update __P((caddr_t, vchar_t *)); 182extern vchar_t *eay_sha2_384_final __P((caddr_t)); 183extern vchar_t *eay_sha2_384_one __P((vchar_t *)); 184#endif 185extern int eay_sha2_384_hashlen __P((void)); 186 187#if defined(WITH_SHA2) 188extern caddr_t eay_sha2_256_init __P((void)); 189extern void eay_sha2_256_update __P((caddr_t, vchar_t *)); 190extern vchar_t *eay_sha2_256_final __P((caddr_t)); 191extern vchar_t *eay_sha2_256_one __P((vchar_t *)); 192#endif 193extern int eay_sha2_256_hashlen __P((void)); 194 195/* SHA functions */ 196extern caddr_t eay_sha1_init __P((void)); 197extern void eay_sha1_update __P((caddr_t, vchar_t *)); 198extern vchar_t *eay_sha1_final __P((caddr_t)); 199extern vchar_t *eay_sha1_one __P((vchar_t *)); 200extern int eay_sha1_hashlen __P((void)); 201 202/* MD5 functions */ 203extern caddr_t eay_md5_init __P((void)); 204extern void eay_md5_update __P((caddr_t, vchar_t *)); 205extern vchar_t *eay_md5_final __P((caddr_t)); 206extern vchar_t *eay_md5_one __P((vchar_t *)); 207extern int eay_md5_hashlen __P((void)); 208 209/* RNG */ 210extern vchar_t *eay_set_random __P((u_int32_t)); 211extern u_int32_t eay_random __P((void)); 212 213/* DH */ 214extern int eay_dh_generate __P((vchar_t *, u_int32_t, u_int, vchar_t **, vchar_t **)); 215extern int eay_dh_compute __P((vchar_t *, u_int32_t, vchar_t *, vchar_t *, vchar_t *, vchar_t **)); 216 217/* Base 64 */ 218vchar_t *base64_encode(char *in, long inlen); 219vchar_t *base64_decode(char *in, long inlen); 220 221RSA *base64_pubkey2rsa(char *in); 222RSA *bignum_pubkey2rsa(BIGNUM *in); 223 224/* misc */ 225extern int eay_revbnl __P((vchar_t *)); 226#include <openssl/bn.h> 227extern int eay_v2bn __P((BIGNUM **, vchar_t *)); 228extern int eay_bn2v __P((vchar_t **, BIGNUM *)); 229 230extern const char *eay_version __P((void)); 231 232#define CBC_BLOCKLEN 8 233#define IPSEC_ENCRYPTKEYLEN 8 234 235#endif /* _CRYPTO_OPENSSL_H */ 236