summaryrefslogtreecommitdiff
path: root/includes/gnutls/crypto.h
blob: b4f5a6ff50255a2badd79c6757b43cd6db4876ea (plain)
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
/*
 * Copyright (C) 2008 Free Software Foundation
 *
 * Author: Nikos Mavrogiannopoulos
 *
 * This file is part of GNUTLS.
 *
 * The GNUTLS library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 * USA
 *
 */

#ifndef GNUTLS_CRYPTO_H
# define GNUTLS_CRYPTO_H

typedef struct gnutls_crypto_cipher {
  int (*init)( void** ctx);
  int (*setkey)( void* ctx, const void * key, int keysize);
  int (*setiv)(void* ctx, const void* iv, int ivsize);
  int (*encrypt)(void* ctx, const void* plain, int plainsize, void* encr, int encrsize);
  int (*decrypt)(void* ctx, const void* encr, int encrsize, void* plain, int plainsize);
  void (*deinit)( void* ctx);
} gnutls_crypto_cipher_st;

typedef struct gnutls_crypto_mac {
  int (*init)( void** ctx);
  int (*setkey)( void* ctx, const void * key, int keysize);
  int (*hash)( void* ctx, const void * text, int textsize);
  int (*copy)( void** dst_ctx, void* src_ctx);
  int (*output) ( void* src_ctx, void* digest, int digestsize);
  void (*deinit)( void* ctx);
} gnutls_crypto_mac_st;

/* the same... setkey should be null */
typedef gnutls_crypto_mac_st gnutls_crypto_digest_st;

/* priority: infinity for backend algorithms, 90 for kernel algorithms - lowest wins 
 */
int gnutls_crypto_cipher_register( gnutls_cipher_algorithm_t algorithm, int priority, gnutls_crypto_cipher_st* s);
int gnutls_crypto_mac_register( gnutls_mac_algorithm_t algorithm, int priority, gnutls_crypto_mac_st* s);
int gnutls_crypto_digest_register( gnutls_digest_algorithm_t algorithm, int priority, gnutls_crypto_digest_st* s);

#endif