1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
/* -*- Mode: C; c-file-style: "bsd" -*-
* cipher.h
* Copyright (C) 2003 Timo Schulz
*
* This file is part of OpenCDK.
*
* OpenCDK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* OpenCDK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenCDK; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef CDK_CIPHER_H
#define CDK_CIPHER_H
#define MAX_BLOCKSIZE 16
typedef int (*cipher_setkey_t) (void *c,
const unsigned char *key,
unsigned keylen);
typedef void (*cipher_encrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf);
typedef void (*cipher_decrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf);
typedef struct {
const char *name;
int id;
size_t blocksize;
size_t keylen;
size_t contextsize;
cipher_setkey_t setkey;
cipher_encrypt_t encrypt;
cipher_decrypt_t decrypt;
} cipher_spec_t;
extern cipher_spec_t cipher_spec_blowfish;
extern cipher_spec_t cipher_spec_twofish;
extern cipher_spec_t cipher_spec_3des;
extern cipher_spec_t cipher_spec_cast5;
extern cipher_spec_t cipher_spec_aes;
extern cipher_spec_t cipher_spec_aes192;
extern cipher_spec_t cipher_spec_aes256;
cdk_cipher_hd_t cdk_cipher_new( int algo, int pgp_sync );
cdk_cipher_hd_t cdk_cipher_open( int algo, int pgp_sync,
const byte * key, size_t keylen,
const byte * ivbuf, size_t ivlen );
void cdk_cipher_close( cdk_cipher_hd_t hd );
int cdk_cipher_encrypt( cdk_cipher_hd_t hd,
byte * outbuf, const byte *inbuf, size_t n );
int cdk_cipher_decrypt( cdk_cipher_hd_t hd,
byte * outbuf, const byte *inbuf, size_t n );
void cdk_cipher_sync( cdk_cipher_hd_t hd );
int cdk_cipher_setiv( cdk_cipher_hd_t hd, const byte *ivbuf, size_t n );
int cdk_cipher_setkey( cdk_cipher_hd_t hd, const byte *keybuf, size_t n );
int cdk_cipher_get_algo_blklen( int algo );
int cdk_cipher_get_algo_keylen( int algo );
int cdk_cipher_test_algo( int algo );
#endif /*CDK_CIPHER_H*/
|