Imported Upstream version 2.7
[ossec-hids.git] / src / os_crypto / blowfish / bf_op.c
1 /*    $OSSEC, os_crypto/blowfish_op.c, v0.2, 2005/09/17, Daniel B. Cid$  */
2
3 /* Copyright (C) 2009 Trend Micro Inc.
4  * All right reserved.
5  *
6  * This program is a free software; you can redistribute it
7  * and/or modify it under the terms of the GNU General Public
8  * License (version 2) as published by the FSF - Free Software
9  * Foundation
10  */
11
12 /* v0.2 (2005/09/17): uchar fixes
13  * v0.1 (2005/01/29)
14  */
15
16 /* OS_crypto/blowfish Library.
17  * APIs for many crypto operations.
18  */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23
24 #include "blowfish.h"
25
26 #include "bf_op.h"
27
28 typedef unsigned char uchar;
29
30 int OS_BF_Str(char *input, char *output, char *charkey,
31                 long size, short int action)
32 {
33     BF_KEY key;
34     static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
35     unsigned char iv[8];
36
37     memcpy(iv,cbc_iv,sizeof(iv));
38
39     BF_set_key(&key, strlen(charkey), (uchar *)charkey);
40
41     BF_cbc_encrypt((uchar *)input, (uchar *)output, size,
42             &key, iv, action);
43
44     return(1);
45 }
46
47 /* EOF */