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 import ocean.transition; 27 28 public import ocean.util.cipher.gcrypt.c.general; 29 30 extern (C): 31 32 /// See original's library documentation for details. 33 gcry_error_t gcry_cipher_open (gcry_cipher_hd_t* hd, gcry_cipher_algos algo, 34 gcry_cipher_modes mode, uint flags); 35 36 /// See original's library documentation for details. 37 void gcry_cipher_close (gcry_cipher_hd_t h); 38 39 /// See original's library documentation for details. 40 gcry_error_t gcry_cipher_setkey (gcry_cipher_hd_t h, Const!(void)* k, size_t l); 41 42 /// See original's library documentation for details. 43 gcry_error_t gcry_cipher_setiv (gcry_cipher_hd_t h, Const!(void)* k, size_t l); 44 45 46 /// See original's library documentation for details. 47 gcry_error_t gcry_cipher_encrypt (gcry_cipher_hd_t h, Const!(void)* out_, 48 size_t outsize, Const!(void)* in_, size_t inlen); 49 50 /// See original's library documentation for details. 51 gcry_error_t gcry_cipher_decrypt (gcry_cipher_hd_t h, Const!(void)* out_, 52 size_t outsize, Const!(void)* in_, size_t inlen); 53 54 55 /// See original's library documentation for details. 56 size_t gcry_cipher_get_algo_blklen (int algo); 57 58 /// See original's library documentation for details. 59 size_t gcry_cipher_get_algo_keylen (int algo); 60 61 /// See original's library documentation for details. 62 struct gcry_cipher_handle; 63 alias gcry_cipher_handle* gcry_cipher_hd_t; 64 65 66 /// See original's library documentation for details. 67 enum gcry_cipher_algos 68 { 69 GCRY_CIPHER_NONE = 0, 70 GCRY_CIPHER_IDEA = 1, 71 GCRY_CIPHER_3DES = 2, 72 GCRY_CIPHER_CAST5 = 3, 73 GCRY_CIPHER_BLOWFISH = 4, 74 GCRY_CIPHER_SAFER_SK128 = 5, 75 GCRY_CIPHER_DES_SK = 6, 76 GCRY_CIPHER_AES = 7, 77 GCRY_CIPHER_AES192 = 8, 78 GCRY_CIPHER_AES256 = 9, 79 GCRY_CIPHER_TWOFISH = 10, 80 81 GCRY_CIPHER_ARCFOUR = 301, 82 GCRY_CIPHER_DES = 302, 83 GCRY_CIPHER_TWOFISH128 = 303, 84 GCRY_CIPHER_SERPENT128 = 304, 85 GCRY_CIPHER_SERPENT192 = 305, 86 GCRY_CIPHER_SERPENT256 = 306, 87 GCRY_CIPHER_RFC2268_40 = 307, 88 GCRY_CIPHER_RFC2268_128 = 308, 89 GCRY_CIPHER_SEED = 309, 90 GCRY_CIPHER_CAMELLIA128 = 310, 91 GCRY_CIPHER_CAMELLIA192 = 311, 92 GCRY_CIPHER_CAMELLIA256 = 312, 93 GCRY_CIPHER_SALSA20 = 313, 94 GCRY_CIPHER_SALSA20R12 = 314, 95 GCRY_CIPHER_GOST28147 = 315, 96 GCRY_CIPHER_CHACHA20 = 316 97 } 98 99 /// See original's library documentation for details. 100 enum gcry_cipher_modes 101 { 102 GCRY_CIPHER_MODE_NONE = 0, /* Not yet specified. */ 103 GCRY_CIPHER_MODE_ECB = 1, /* Electronic codebook. */ 104 GCRY_CIPHER_MODE_CFB = 2, /* Cipher feedback. */ 105 GCRY_CIPHER_MODE_CBC = 3, /* Cipher block chaining. */ 106 GCRY_CIPHER_MODE_STREAM = 4, /* Used with stream ciphers. */ 107 GCRY_CIPHER_MODE_OFB = 5, /* Outer feedback. */ 108 GCRY_CIPHER_MODE_CTR = 6, /* Counter. */ 109 GCRY_CIPHER_MODE_AESWRAP = 7, /* AES-WRAP algorithm. */ 110 GCRY_CIPHER_MODE_CCM = 8, /* Counter with CBC-MAC. */ 111 GCRY_CIPHER_MODE_GCM = 9, /* Galois Counter Mode. */ 112 GCRY_CIPHER_MODE_POLY1305 = 10, /* Poly1305 based AEAD mode. */ 113 GCRY_CIPHER_MODE_OCB = 11 /* OCB3 mode. */ 114 } 115 116