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