]> git.saurik.com Git - apple/xnu.git/blame - EXTERNAL_HEADERS/corecrypto/ccpad.h
xnu-2782.40.9.tar.gz
[apple/xnu.git] / EXTERNAL_HEADERS / corecrypto / ccpad.h
CommitLineData
316670eb
A
1/*
2 * ccpad.h
3 * corecrypto
4 *
5 * Created by Michael Brouwer on 12/6/10.
6 * Copyright 2010,2011 Apple Inc. All rights reserved.
7 *
8 */
9
10#ifndef _CORECRYPTO_CCPAD_H_
11#define _CORECRYPTO_CCPAD_H_
12
13#include <corecrypto/ccmode.h>
14
15/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
16void ccpad_cts_decrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
17 size_t nbytes, const void *in, void *out);
316670eb
A
18
19/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
20void ccpad_cts_encrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
21 size_t nbytes, const void *in, void *out);
316670eb
A
22
23/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
24void ccpad_cts1_decrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
25 size_t nbytes, const void *in, void *out);
316670eb
A
26
27/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
28void ccpad_cts1_encrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
29 size_t nbytes, const void *in, void *out);
316670eb 30/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
31void ccpad_cts2_decrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
32 size_t nbytes, const void *in, void *out);
316670eb
A
33
34/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
35void ccpad_cts2_encrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
36 size_t nbytes, const void *in, void *out);
316670eb 37/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
38void ccpad_cts3_decrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
39 size_t nbytes, const void *in, void *out);
316670eb
A
40
41/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
42void ccpad_cts3_encrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
43 size_t nbytes, const void *in, void *out);
316670eb
A
44
45/* Contract is nbytes is non zero and a multiple of block_size. Furthermore in is nbytes long and out is nbytes long. Returns number of bytes written to out (technically we always write nbytes to out but the returned value is the number of bytes decrypted after removal of padding.
46
47 To be safe we remove the entire offending block if the pkcs7 padding checks failed. However we purposely don't report the failure to decode the padding since any use of this error leads to potential security exploits. So currently there is no way to distinguish between a full block of padding and bad padding.
48 */
fe8ab488
A
49size_t ccpad_pkcs7_decrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
50 size_t nbytes, const void *in, void *out);
316670eb
A
51
52/* Contract is in is nbytes long. Writes (nbytes / block_size) + 1 times block_size to out. In other words, out must be nbytes rounded down to the closest multiple of block_size plus block_size bytes. */
fe8ab488
A
53void ccpad_pkcs7_encrypt(const struct ccmode_cbc *cbc, cccbc_ctx *ctx, cccbc_iv *iv,
54 size_t nbytes, const void *in, void *out);
55
56/* Contract is 'don't break CommonCrypto functionality that allows PKCS7 padding with ECB mode'. This is basically the same routines above, without an IV, because calling
57 crypt with an IV makes ecb cry (and crash) */
58
59size_t ccpad_pkcs7_ecb_decrypt(const struct ccmode_ecb *ecb, ccecb_ctx *ecb_key,
60 size_t nbytes, const void *in, void *out);
61
62void ccpad_pkcs7_ecb_encrypt(const struct ccmode_ecb *ecb, ccecb_ctx *ctx,
63 size_t nbytes, const void *in, void *out);
316670eb
A
64
65/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
66void ccpad_xts_decrypt(const struct ccmode_xts *xts, ccxts_ctx *ctx, ccxts_tweak *tweak,
67 size_t nbytes, const void *in, void *out);
316670eb
A
68
69/* Contract is nbytes is at least 1 block + 1 byte. Also in is nbytes long out is nbytes long. */
fe8ab488
A
70void ccpad_xts_encrypt(const struct ccmode_xts *xts, ccxts_ctx *ctx, ccxts_tweak *tweak,
71 size_t nbytes, const void *in, void *out);
316670eb
A
72
73#endif /* _CORECRYPTO_CCPAD_H_ */