1 /* ==================================================================== 2 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. 3 * 4 * Rights for redistribution and usage in source and binary 5 * forms are granted according to the OpenSSL license. 6 */ 7 module deimos.openssl.modes; 8 9 import deimos.openssl._d_util; 10 11 import core.stdc.config; 12 13 alias ExternC!(void function(const(ubyte[16])* in_, 14 ubyte[16]* out_, 15 const(void)* key)) block128_f; 16 17 alias ExternC!(void function(const(ubyte)* in_, ubyte* out_, 18 size_t blocks, const(void)* key, 19 const(ubyte[16])* ivec)) ctr128_f; 20 21 alias ExternC!(void function(const(ubyte)* in_, ubyte* out_, 22 size_t blocks, const(void)* key, 23 const(ubyte[16])* ivec, ubyte[16]* cmac)) ccm128_f; 24 25 alias ExternC!(void function(const(ubyte)* in_, ubyte* out_, 26 size_t len, const(void)* key, 27 ubyte[16]* ivec, int enc)) cbc128_f; 28 29 void CRYPTO_cbc128_encrypt(const(ubyte)* in_, ubyte* out_, 30 size_t len, const(void)* key, 31 ubyte[16]* ivec, block128_f block); 32 void CRYPTO_cbc128_decrypt(const(ubyte)* in_, ubyte* out_, 33 size_t len, const(void)* key, 34 ubyte[16]* ivec, block128_f block); 35 36 void CRYPTO_ctr128_encrypt_ctr32(const(ubyte)* in_, ubyte* out_, 37 size_t len, const(void)* key, 38 ubyte[16]* ivec, ubyte[16]* ecount_buf, 39 uint *num, ctr128_f ctr); 40 41 void CRYPTO_ctr128_encrypt(const(ubyte)* in_, ubyte* out_, 42 size_t len, const(void)* key, 43 ubyte[16]* ivec, ubyte[16]* ecount_buf, 44 uint* num, block128_f block); 45 46 void CRYPTO_ofb128_encrypt(const(ubyte)* in_, ubyte* out_, 47 size_t len, const(void)* key, 48 ubyte[16]* ivec, int* num, 49 block128_f block); 50 51 void CRYPTO_cfb128_encrypt(const(ubyte)* in_, ubyte* out_, 52 size_t len, const(void)* key, 53 ubyte[16]* ivec, int* num, 54 int enc, block128_f block); 55 void CRYPTO_cfb128_8_encrypt(const(ubyte)* in_, ubyte* out_, 56 size_t length, const(void)* key, 57 ubyte[16]* ivec, int* num, 58 int enc, block128_f block); 59 void CRYPTO_cfb128_1_encrypt(const(ubyte)* in_, ubyte* out_, 60 size_t bits, const(void)* key, 61 ubyte[16]* ivec, int* num, 62 int enc, block128_f block); 63 64 size_t CRYPTO_cts128_encrypt_block(const(ubyte)* in_, ubyte* out_, 65 size_t len, const(void)* key, 66 ubyte[16]* ivec, block128_f block); 67 size_t CRYPTO_cts128_encrypt(const(ubyte)* in_, ubyte* out_, 68 size_t len, const(void)* key, 69 ubyte[16]* ivec, cbc128_f cbc); 70 size_t CRYPTO_cts128_decrypt_block(const(ubyte)* in_, ubyte* out_, 71 size_t len, const(void)* key, 72 ubyte[16]* ivec, block128_f block); 73 size_t CRYPTO_cts128_decrypt(const(ubyte)* in_, ubyte* out_, 74 size_t len, const(void)* key, 75 ubyte[16]* ivec, cbc128_f cbc); 76 77 size_t CRYPTO_nistcts128_encrypt_block(const(ubyte)* in_, ubyte* out_, 78 size_t len, const void *key, 79 ubyte[16]* ivec, block128_f block); 80 size_t CRYPTO_nistcts128_encrypt(const(ubyte)* in_, ubyte* out_, 81 size_t len, const void *key, 82 ubyte[16]* ivec, cbc128_f cbc); 83 size_t CRYPTO_nistcts128_decrypt_block(const(ubyte)* in_, ubyte* out_, 84 size_t len, const void *key, 85 ubyte[16]* ivec, block128_f block); 86 size_t CRYPTO_nistcts128_decrypt(const(ubyte)* in_, ubyte* out_, 87 size_t len, const void *key, 88 ubyte[16]* ivec, cbc128_f cbc); 89 90 struct gcm128_context; 91 alias gcm128_context GCM128_CONTEXT; 92 93 GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block); 94 void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx,void *key,block128_f block); 95 void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const(ubyte)* iv, 96 size_t len); 97 int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const(ubyte)* aad, 98 size_t len); 99 int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, 100 const(ubyte)* in_, ubyte* out_, 101 size_t len); 102 int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, 103 const(ubyte)* in_, ubyte* out_, 104 size_t len); 105 int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, 106 const(ubyte)* in_, ubyte* out_, 107 size_t len, ctr128_f stream); 108 int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, 109 const(ubyte)* in_, ubyte* out_, 110 size_t len, ctr128_f stream); 111 int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx,const(ubyte)* tag, 112 size_t len); 113 void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, ubyte* tag, size_t len); 114 void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx); 115 116 struct ccm128_context; 117 alias ccm128_context CCM128_CONTEXT; 118 119 void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx, 120 uint M, uint L, void *key,block128_f block); 121 int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, 122 const(ubyte)* nonce, size_t nlen, size_t mlen); 123 void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, 124 const(ubyte)* aad, size_t alen); 125 int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, 126 const(ubyte)* inp, ubyte* out_, size_t len); 127 int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, 128 const(ubyte)* inp, ubyte* out_, size_t len); 129 int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, 130 const(ubyte)* inp, ubyte* out_, size_t len, 131 ccm128_f stream); 132 int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, 133 const(ubyte)* inp, ubyte* out_, size_t len, 134 ccm128_f stream); 135 size_t CRYPTO_ccm128_tag(CCM128_CONTEXT* ctx, ubyte* tag, size_t len); 136 137 struct xts128_context; 138 alias xts128_context XTS128_CONTEXT; 139 140 int CRYPTO_xts128_encrypt(const(XTS128_CONTEXT)* ctx, const(ubyte[16])* iv, 141 const(ubyte)* inp, ubyte* out_, size_t len, int enc);