1 /* $OpenBSD: modes.h,v 1.3 2018/07/24 10:47:19 bcook Exp $ */ 2 /* ==================================================================== 3 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. 4 * 5 * Rights for redistribution and usage in source and binary 6 * forms are granted according to the OpenSSL license. 7 */ 8 module libressl_d.openssl.modes; 9 10 11 public import core.stdc.stddef; 12 13 extern (C): 14 nothrow @nogc: 15 16 alias block128_f = extern (C) nothrow @nogc void function(const (ubyte)* in_, ubyte* out_, const (void)* key); 17 18 alias cbc128_f = extern (C) nothrow @nogc void function(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, int enc); 19 20 alias ctr128_f = extern (C) nothrow @nogc void function(const (ubyte)* in_, ubyte* out_, size_t blocks, const (void)* key, const (ubyte)* ivec); 21 22 alias ccm128_f = extern (C) nothrow @nogc void function(const (ubyte)* in_, ubyte* out_, size_t blocks, const (void)* key, const (ubyte)* ivec, ubyte* cmac); 23 24 void CRYPTO_cbc128_encrypt(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .block128_f block); 25 void CRYPTO_cbc128_decrypt(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .block128_f block); 26 27 void CRYPTO_ctr128_encrypt(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, ubyte* ecount_buf, uint* num, .block128_f block); 28 29 void CRYPTO_ctr128_encrypt_ctr32(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, ubyte* ecount_buf, uint* num, .ctr128_f ctr); 30 31 void CRYPTO_ofb128_encrypt(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, int* num, .block128_f block); 32 33 void CRYPTO_cfb128_encrypt(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, int* num, int enc, .block128_f block); 34 void CRYPTO_cfb128_8_encrypt(const (ubyte)* in_, ubyte* out_, size_t length_, const (void)* key, ubyte* ivec, int* num, int enc, .block128_f block); 35 void CRYPTO_cfb128_1_encrypt(const (ubyte)* in_, ubyte* out_, size_t bits, const (void)* key, ubyte* ivec, int* num, int enc, .block128_f block); 36 37 size_t CRYPTO_cts128_encrypt_block(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .block128_f block); 38 size_t CRYPTO_cts128_encrypt(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .cbc128_f cbc); 39 size_t CRYPTO_cts128_decrypt_block(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .block128_f block); 40 size_t CRYPTO_cts128_decrypt(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .cbc128_f cbc); 41 42 size_t CRYPTO_nistcts128_encrypt_block(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .block128_f block); 43 size_t CRYPTO_nistcts128_encrypt(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .cbc128_f cbc); 44 size_t CRYPTO_nistcts128_decrypt_block(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .block128_f block); 45 size_t CRYPTO_nistcts128_decrypt(const (ubyte)* in_, ubyte* out_, size_t len, const (void)* key, ubyte* ivec, .cbc128_f cbc); 46 47 struct gcm128_context; 48 alias GCM128_CONTEXT = .gcm128_context; 49 50 .GCM128_CONTEXT* CRYPTO_gcm128_new(void* key, .block128_f block); 51 void CRYPTO_gcm128_init(.GCM128_CONTEXT* ctx, void* key, .block128_f block); 52 void CRYPTO_gcm128_setiv(.GCM128_CONTEXT* ctx, const (ubyte)* iv, size_t len); 53 int CRYPTO_gcm128_aad(.GCM128_CONTEXT* ctx, const (ubyte)* aad, size_t len); 54 int CRYPTO_gcm128_encrypt(.GCM128_CONTEXT* ctx, const (ubyte)* in_, ubyte* out_, size_t len); 55 int CRYPTO_gcm128_decrypt(.GCM128_CONTEXT* ctx, const (ubyte)* in_, ubyte* out_, size_t len); 56 int CRYPTO_gcm128_encrypt_ctr32(.GCM128_CONTEXT* ctx, const (ubyte)* in_, ubyte* out_, size_t len, .ctr128_f stream); 57 int CRYPTO_gcm128_decrypt_ctr32(.GCM128_CONTEXT* ctx, const (ubyte)* in_, ubyte* out_, size_t len, .ctr128_f stream); 58 int CRYPTO_gcm128_finish(.GCM128_CONTEXT* ctx, const (ubyte)* tag, size_t len); 59 void CRYPTO_gcm128_tag(.GCM128_CONTEXT* ctx, ubyte* tag, size_t len); 60 void CRYPTO_gcm128_release(.GCM128_CONTEXT* ctx); 61 62 struct ccm128_context; 63 alias CCM128_CONTEXT = .ccm128_context; 64 65 void CRYPTO_ccm128_init(.CCM128_CONTEXT* ctx, uint M, uint L, void* key, .block128_f block); 66 int CRYPTO_ccm128_setiv(.CCM128_CONTEXT* ctx, const (ubyte)* nonce, size_t nlen, size_t mlen); 67 void CRYPTO_ccm128_aad(.CCM128_CONTEXT* ctx, const (ubyte)* aad, size_t alen); 68 int CRYPTO_ccm128_encrypt(.CCM128_CONTEXT* ctx, const (ubyte)* inp, ubyte* out_, size_t len); 69 int CRYPTO_ccm128_decrypt(.CCM128_CONTEXT* ctx, const (ubyte)* inp, ubyte* out_, size_t len); 70 int CRYPTO_ccm128_encrypt_ccm64(.CCM128_CONTEXT* ctx, const (ubyte)* inp, ubyte* out_, size_t len, .ccm128_f stream); 71 int CRYPTO_ccm128_decrypt_ccm64(.CCM128_CONTEXT* ctx, const (ubyte)* inp, ubyte* out_, size_t len, .ccm128_f stream); 72 size_t CRYPTO_ccm128_tag(.CCM128_CONTEXT* ctx, ubyte* tag, size_t len); 73 74 struct xts128_context; 75 alias XTS128_CONTEXT = .xts128_context; 76 77 int CRYPTO_xts128_encrypt(const (.XTS128_CONTEXT)* ctx, const (ubyte)* iv, const (ubyte)* inp, ubyte* out_, size_t len, int enc);