1103423Snectar/* 2178825Sdfr * Copyright (c) 2002 - 2005 Kungliga Tekniska H�gskolan 3103423Snectar * (Royal Institute of Technology, Stockholm, Sweden). 4103423Snectar * All rights reserved. 5103423Snectar * 6103423Snectar * Redistribution and use in source and binary forms, with or without 7103423Snectar * modification, are permitted provided that the following conditions 8103423Snectar * are met: 9103423Snectar * 10103423Snectar * 1. Redistributions of source code must retain the above copyright 11103423Snectar * notice, this list of conditions and the following disclaimer. 12103423Snectar * 13103423Snectar * 2. Redistributions in binary form must reproduce the above copyright 14103423Snectar * notice, this list of conditions and the following disclaimer in the 15103423Snectar * documentation and/or other materials provided with the distribution. 16103423Snectar * 17103423Snectar * 3. Neither the name of the Institute nor the names of its contributors 18103423Snectar * may be used to endorse or promote products derived from this software 19103423Snectar * without specific prior written permission. 20103423Snectar * 21103423Snectar * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22103423Snectar * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23103423Snectar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24103423Snectar * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25103423Snectar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26103423Snectar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27103423Snectar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28103423Snectar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29103423Snectar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30103423Snectar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31103423Snectar * SUCH DAMAGE. 32103423Snectar */ 33103423Snectar 34103423Snectar#ifdef HAVE_CONFIG_H 35103423Snectar#include <config.h> 36178825SdfrRCSID("$Id: make_crypto.c 19477 2006-12-20 19:51:53Z lha $"); 37103423Snectar#endif 38103423Snectar#include <stdio.h> 39103423Snectar#include <string.h> 40103423Snectar#include <stdlib.h> 41103423Snectar#include <ctype.h> 42103423Snectar 43103423Snectarint 44103423Snectarmain(int argc, char **argv) 45103423Snectar{ 46103423Snectar char *p; 47103423Snectar FILE *f; 48103423Snectar if(argc != 2) { 49103423Snectar fprintf(stderr, "Usage: make_crypto file\n"); 50103423Snectar exit(1); 51103423Snectar } 52178825Sdfr if (strcmp(argv[1], "--version") == 0) { 53178825Sdfr printf("some version"); 54178825Sdfr return 0; 55178825Sdfr } 56103423Snectar f = fopen(argv[1], "w"); 57103423Snectar if(f == NULL) { 58103423Snectar perror(argv[1]); 59103423Snectar exit(1); 60103423Snectar } 61103423Snectar for(p = argv[1]; *p; p++) 62178825Sdfr if(!isalnum((unsigned char)*p)) 63103423Snectar *p = '_'; 64103423Snectar fprintf(f, "#ifndef __%s__\n", argv[1]); 65103423Snectar fprintf(f, "#define __%s__\n", argv[1]); 66103423Snectar#ifdef HAVE_OPENSSL 67178825Sdfr fputs("#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY\n", f); 68120945Snectar fputs("#define OPENSSL_DES_LIBDES_COMPATIBILITY\n", f); 69178825Sdfr fputs("#endif\n", f); 70178825Sdfr fputs("#include <openssl/evp.h>\n", f); 71103423Snectar fputs("#include <openssl/des.h>\n", f); 72103423Snectar fputs("#include <openssl/rc4.h>\n", f); 73178825Sdfr fputs("#include <openssl/rc2.h>\n", f); 74178825Sdfr fputs("#include <openssl/md2.h>\n", f); 75103423Snectar fputs("#include <openssl/md4.h>\n", f); 76103423Snectar fputs("#include <openssl/md5.h>\n", f); 77103423Snectar fputs("#include <openssl/sha.h>\n", f); 78120945Snectar fputs("#include <openssl/aes.h>\n", f); 79178825Sdfr fputs("#include <openssl/ui.h>\n", f); 80178825Sdfr fputs("#include <openssl/rand.h>\n", f); 81178825Sdfr fputs("#include <openssl/engine.h>\n", f); 82178825Sdfr fputs("#include <openssl/pkcs12.h>\n", f); 83178825Sdfr fputs("#include <openssl/pem.h>\n", f); 84178825Sdfr fputs("#include <openssl/hmac.h>\n", f); 85178825Sdfr fputs("#ifndef BN_is_negative\n", f); 86178825Sdfr fputs("#define BN_set_negative(bn, flag) ((bn)->neg=(flag)?1:0)\n", f); 87178825Sdfr fputs("#define BN_is_negative(bn) ((bn)->neg != 0)\n", f); 88178825Sdfr fputs("#endif\n", f); 89103423Snectar#else 90178825Sdfr fputs("#ifdef KRB5\n", f); 91178825Sdfr fputs("#include <krb5-types.h>\n", f); 92178825Sdfr fputs("#endif\n", f); 93178825Sdfr fputs("#include <hcrypto/evp.h>\n", f); 94178825Sdfr fputs("#include <hcrypto/des.h>\n", f); 95178825Sdfr fputs("#include <hcrypto/md2.h>\n", f); 96178825Sdfr fputs("#include <hcrypto/md4.h>\n", f); 97178825Sdfr fputs("#include <hcrypto/md5.h>\n", f); 98178825Sdfr fputs("#include <hcrypto/sha.h>\n", f); 99178825Sdfr fputs("#include <hcrypto/rc4.h>\n", f); 100178825Sdfr fputs("#include <hcrypto/rc2.h>\n", f); 101178825Sdfr fputs("#include <hcrypto/aes.h>\n", f); 102178825Sdfr fputs("#include <hcrypto/ui.h>\n", f); 103178825Sdfr fputs("#include <hcrypto/rand.h>\n", f); 104178825Sdfr fputs("#include <hcrypto/engine.h>\n", f); 105178825Sdfr fputs("#include <hcrypto/pkcs12.h>\n", f); 106178825Sdfr fputs("#include <hcrypto/hmac.h>\n", f); 107103423Snectar#endif 108103423Snectar fprintf(f, "#endif /* __%s__ */\n", argv[1]); 109103423Snectar fclose(f); 110103423Snectar exit(0); 111103423Snectar} 112