Add.
[shishi.git] / lib / crypto-null.c
blob82eef51f9e6dd5e6dd4303741cab3f2d997d88db
1 /* crypto-null.c --- NULL crypto functions
2 * Copyright (C) 2002, 2003, 2004 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "internal.h"
24 #include "crypto.h"
26 static int
27 null_encrypt (Shishi * handle,
28 Shishi_key * key,
29 int keyusage,
30 const char *iv, size_t ivlen,
31 char **ivout, size_t * ivoutlen,
32 const char *in, size_t inlen, char **out, size_t * outlen)
34 *outlen = inlen;
35 *out = xmalloc (*outlen);
36 memcpy (*out, in, inlen);
38 if (ivout)
39 *ivout = NULL;
40 if (ivoutlen)
41 *ivoutlen = 0;
43 return SHISHI_OK;
46 static int
47 null_decrypt (Shishi * handle,
48 Shishi_key * key,
49 int keyusage,
50 const char *iv, size_t ivlen,
51 char **ivout, size_t * ivoutlen,
52 const char *in, size_t inlen, char **out, size_t * outlen)
54 *outlen = inlen;
55 *out = xmalloc (*outlen);
56 memcpy (*out, in, inlen);
58 if (ivout)
59 *ivout = NULL;
60 if (ivoutlen)
61 *ivoutlen = 0;
63 return SHISHI_OK;
66 static int
67 null_random_to_key (Shishi * handle,
68 const char *rnd, size_t rndlen, Shishi_key * outkey)
70 return SHISHI_OK;
73 static int
74 null_string_to_key (Shishi * handle,
75 const char *password, size_t passwordlen,
76 const char *salt, size_t saltlen,
77 const char *parameter, Shishi_key * outkey)
79 return SHISHI_OK;
82 cipherinfo null_info = {
83 SHISHI_NULL,
84 "NULL",
89 SHISHI_RSA_MD5,
90 null_random_to_key,
91 null_string_to_key,
92 null_encrypt,
93 null_decrypt