| 1 |
/*
|
| 2 |
+----------------------------------------------------------------------+
|
| 3 |
| hash: hashing library for IBM DB2 |
|
| 4 |
+----------------------------------------------------------------------+
|
| 5 |
| Copyright (c) 2007-2008 Helmut K. C. Tessarek |
|
| 6 |
+----------------------------------------------------------------------+
|
| 7 |
| Licensed under the Apache License, Version 2.0 (the "License"); you |
|
| 8 |
| may not use this file except in compliance with the License. You may |
|
| 9 |
| obtain a copy of the License at |
|
| 10 |
| http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 |
| |
|
| 12 |
| Unless required by applicable law or agreed to in writing, software |
|
| 13 |
| distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
|
| 15 |
| implied. See the License for the specific language governing |
|
| 16 |
| permissions and limitations under the License. |
|
| 17 |
+----------------------------------------------------------------------+
|
| 18 |
| Author: Helmut K. C. Tessarek |
|
| 19 |
+----------------------------------------------------------------------+
|
| 20 |
| Website: http://mod-auth-ibmdb2.sourceforge.net |
|
| 21 |
+----------------------------------------------------------------------+
|
| 22 |
*/
|
| 23 |
|
| 24 |
/* $Id: hash.c,v 1.3 2008/01/04 07:58:37 tessus Exp $ */
|
| 25 |
|
| 26 |
#include <stdio.h>
|
| 27 |
#include <sqludf.h>
|
| 28 |
#include <sqlca.h>
|
| 29 |
#include <sqlda.h>
|
| 30 |
#include "hash.h"
|
| 31 |
|
| 32 |
/*--------------------------------------------------*/
|
| 33 |
/* function md5: MD5 Hashing */
|
| 34 |
/* */
|
| 35 |
/* input : varchar */
|
| 36 |
/* output: varchar */
|
| 37 |
/*--------------------------------------------------*/
|
| 38 |
|
| 39 |
#ifdef __cplusplus
|
| 40 |
extern "C"
|
| 41 |
#endif
|
| 42 |
void SQL_API_FN md5(
|
| 43 |
SQLUDF_CHAR *in,
|
| 44 |
SQLUDF_CHAR out[33],
|
| 45 |
SQLUDF_SMALLINT *innull,
|
| 46 |
SQLUDF_SMALLINT *outnull,
|
| 47 |
SQLUDF_TRAIL_ARGS) {
|
| 48 |
|
| 49 |
char *t;
|
| 50 |
|
| 51 |
t = mk_hash( in, ALG_MD5 );
|
| 52 |
strcpy( out, t );
|
| 53 |
free( t );
|
| 54 |
|
| 55 |
*outnull = 0;
|
| 56 |
return;
|
| 57 |
}
|
| 58 |
|
| 59 |
/*--------------------------------------------------*/
|
| 60 |
/* function apr_md5: MD5 Hashing as in the htpasswd */
|
| 61 |
/* program from Apache */
|
| 62 |
/* */
|
| 63 |
/* input : varchar */
|
| 64 |
/* output: varchar */
|
| 65 |
/*--------------------------------------------------*/
|
| 66 |
|
| 67 |
#ifdef __cplusplus
|
| 68 |
extern "C"
|
| 69 |
#endif
|
| 70 |
void SQL_API_FN aprmd5(
|
| 71 |
SQLUDF_CHAR *in,
|
| 72 |
SQLUDF_CHAR out[38],
|
| 73 |
SQLUDF_SMALLINT *innull,
|
| 74 |
SQLUDF_SMALLINT *outnull,
|
| 75 |
SQLUDF_TRAIL_ARGS) {
|
| 76 |
|
| 77 |
char *t;
|
| 78 |
|
| 79 |
t = mk_hash( in, ALG_APMD5 );
|
| 80 |
strcpy( out, t );
|
| 81 |
free( t );
|
| 82 |
|
| 83 |
*outnull = 0;
|
| 84 |
return;
|
| 85 |
}
|
| 86 |
|
| 87 |
/*--------------------------------------------------*/
|
| 88 |
/* function apr_crypt: Crypt fuction as in the */
|
| 89 |
/* htpasswd program from Apache */
|
| 90 |
/* */
|
| 91 |
/* input : varchar */
|
| 92 |
/* output: varchar */
|
| 93 |
/*--------------------------------------------------*/
|
| 94 |
|
| 95 |
#ifdef __cplusplus
|
| 96 |
extern "C"
|
| 97 |
#endif
|
| 98 |
void SQL_API_FN aprcrypt(
|
| 99 |
SQLUDF_CHAR *in,
|
| 100 |
SQLUDF_CHAR out[14],
|
| 101 |
SQLUDF_SMALLINT *innull,
|
| 102 |
SQLUDF_SMALLINT *outnull,
|
| 103 |
SQLUDF_TRAIL_ARGS) {
|
| 104 |
|
| 105 |
char *t;
|
| 106 |
|
| 107 |
t = mk_hash( in, ALG_CRYPT );
|
| 108 |
strcpy( out, t );
|
| 109 |
free( t );
|
| 110 |
|
| 111 |
*outnull = 0;
|
| 112 |
return;
|
| 113 |
}
|
| 114 |
|
| 115 |
/*--------------------------------------------------*/
|
| 116 |
/* function apr_sha1: SHA1 fuction as in the */
|
| 117 |
/* htpasswd program from Apache */
|
| 118 |
/* */
|
| 119 |
/* input : varchar */
|
| 120 |
/* output: varchar */
|
| 121 |
/*--------------------------------------------------*/
|
| 122 |
|
| 123 |
#ifdef __cplusplus
|
| 124 |
extern "C"
|
| 125 |
#endif
|
| 126 |
void SQL_API_FN aprsha1(
|
| 127 |
SQLUDF_CHAR *in,
|
| 128 |
SQLUDF_CHAR out[34],
|
| 129 |
SQLUDF_SMALLINT *innull,
|
| 130 |
SQLUDF_SMALLINT *outnull,
|
| 131 |
SQLUDF_TRAIL_ARGS) {
|
| 132 |
|
| 133 |
char *t;
|
| 134 |
|
| 135 |
t = mk_hash( in, ALG_APSHA );
|
| 136 |
strcpy( out, t );
|
| 137 |
free( t );
|
| 138 |
|
| 139 |
*outnull = 0;
|
| 140 |
return;
|
| 141 |
}
|