1 /*******************************************************************************
2 
3     D bindings to the libgcrypt library.
4 
5     Requires linking with libgcrypt:
6 
7         -L-lgcrypt
8 
9     Copyright:
10         Copyright (c) 2009-2016 dunnhumby Germany GmbH.
11         All rights reserved.
12 
13     License:
14         Boost Software License Version 1.0. See LICENSE_BOOST.txt for details.
15         Alternatively, this file may be distributed under the terms of the Tango
16         3-Clause BSD License (see LICENSE_BSD.txt for details).
17 
18         Bear in mind this module provides bindings to an external library that
19         has its own license, which might be more restrictive. Please check the
20         external library license to see which conditions apply for linking.
21 
22 *******************************************************************************/
23 
24 module ocean.util.cipher.gcrypt.c.gcrypt;
25 
26 public import ocean.util.cipher.gcrypt.c.general;
27 
28 extern (C):
29 
30 /// See original's library documentation for details.
31 gcry_error_t gcry_cipher_open (gcry_cipher_hd_t* hd, gcry_cipher_algos algo,
32     gcry_cipher_modes mode, uint flags);
33 
34 /// See original's library documentation for details.
35 void gcry_cipher_close (gcry_cipher_hd_t h);
36 
37 /// See original's library documentation for details.
38 gcry_error_t gcry_cipher_setkey (gcry_cipher_hd_t h, const(void)* k, size_t l);
39 
40 /// See original's library documentation for details.
41 gcry_error_t gcry_cipher_setiv (gcry_cipher_hd_t h, const(void)* k, size_t l);
42 
43 
44 /// See original's library documentation for details.
45 gcry_error_t gcry_cipher_encrypt (gcry_cipher_hd_t h, const(void)* out_,
46     size_t outsize, const(void)* in_, size_t inlen);
47 
48 /// See original's library documentation for details.
49 gcry_error_t gcry_cipher_decrypt (gcry_cipher_hd_t h, const(void)* out_,
50     size_t outsize, const(void)* in_, size_t inlen);
51 
52 
53 /// See original's library documentation for details.
54 size_t gcry_cipher_get_algo_blklen (int algo);
55 
56 /// See original's library documentation for details.
57 size_t gcry_cipher_get_algo_keylen (int algo);
58 
59 /// See original's library documentation for details.
60 struct gcry_cipher_handle;
61 alias gcry_cipher_handle* gcry_cipher_hd_t;
62 
63 
64 /// See original's library documentation for details.
65 enum gcry_cipher_algos
66 {
67     GCRY_CIPHER_NONE        = 0,
68     GCRY_CIPHER_IDEA        = 1,
69     GCRY_CIPHER_3DES        = 2,
70     GCRY_CIPHER_CAST5       = 3,
71     GCRY_CIPHER_BLOWFISH    = 4,
72     GCRY_CIPHER_SAFER_SK128 = 5,
73     GCRY_CIPHER_DES_SK      = 6,
74     GCRY_CIPHER_AES         = 7,
75     GCRY_CIPHER_AES192      = 8,
76     GCRY_CIPHER_AES256      = 9,
77     GCRY_CIPHER_TWOFISH     = 10,
78 
79     GCRY_CIPHER_ARCFOUR     = 301,
80     GCRY_CIPHER_DES         = 302,
81     GCRY_CIPHER_TWOFISH128  = 303,
82     GCRY_CIPHER_SERPENT128  = 304,
83     GCRY_CIPHER_SERPENT192  = 305,
84     GCRY_CIPHER_SERPENT256  = 306,
85     GCRY_CIPHER_RFC2268_40  = 307,
86     GCRY_CIPHER_RFC2268_128 = 308,
87     GCRY_CIPHER_SEED        = 309,
88     GCRY_CIPHER_CAMELLIA128 = 310,
89     GCRY_CIPHER_CAMELLIA192 = 311,
90     GCRY_CIPHER_CAMELLIA256 = 312,
91     GCRY_CIPHER_SALSA20     = 313,
92     GCRY_CIPHER_SALSA20R12  = 314,
93     GCRY_CIPHER_GOST28147   = 315,
94     GCRY_CIPHER_CHACHA20    = 316
95 }
96 
97 /// See original's library documentation for details.
98 enum gcry_cipher_modes
99 {
100     GCRY_CIPHER_MODE_NONE     = 0,   /* Not yet specified. */
101     GCRY_CIPHER_MODE_ECB      = 1,   /* Electronic codebook. */
102     GCRY_CIPHER_MODE_CFB      = 2,   /* Cipher feedback. */
103     GCRY_CIPHER_MODE_CBC      = 3,   /* Cipher block chaining. */
104     GCRY_CIPHER_MODE_STREAM   = 4,   /* Used with stream ciphers. */
105     GCRY_CIPHER_MODE_OFB      = 5,   /* Outer feedback. */
106     GCRY_CIPHER_MODE_CTR      = 6,   /* Counter. */
107     GCRY_CIPHER_MODE_AESWRAP  = 7,   /* AES-WRAP algorithm.  */
108     GCRY_CIPHER_MODE_CCM      = 8,   /* Counter with CBC-MAC.  */
109     GCRY_CIPHER_MODE_GCM      = 9,   /* Galois Counter Mode. */
110     GCRY_CIPHER_MODE_POLY1305 = 10,  /* Poly1305 based AEAD mode. */
111     GCRY_CIPHER_MODE_OCB      = 11   /* OCB3 mode.  */
112 }