]>
git.saurik.com Git - apple/xnu.git/blob - libkern/crypto/corecrypto_chacha20poly1305.c
2 * Copyright (c) 2017 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #include <corecrypto/ccchacha20poly1305.h>
30 #include <libkern/crypto/crypto_internal.h>
31 #include <libkern/crypto/chacha20poly1305.h>
33 static ccchacha20poly1305_fns_t
36 return g_crypto_funcs
->ccchacha20poly1305_fns
;
39 static const struct ccchacha20poly1305_info
*
46 chacha20poly1305_init(chacha20poly1305_ctx
*ctx
, const uint8_t *key
)
48 return fns()->init(info(), ctx
, key
);
52 chacha20poly1305_reset(chacha20poly1305_ctx
*ctx
)
54 return fns()->reset(info(), ctx
);
58 chacha20poly1305_setnonce(chacha20poly1305_ctx
*ctx
, const uint8_t *nonce
)
60 return fns()->setnonce(info(), ctx
, nonce
);
64 chacha20poly1305_incnonce(chacha20poly1305_ctx
*ctx
, uint8_t *nonce
)
66 return fns()->incnonce(info(), ctx
, nonce
);
70 chacha20poly1305_aad(chacha20poly1305_ctx
*ctx
, size_t nbytes
, const void *aad
)
72 return fns()->aad(info(), ctx
, nbytes
, aad
);
76 chacha20poly1305_encrypt(chacha20poly1305_ctx
*ctx
, size_t nbytes
, const void *ptext
, void *ctext
)
78 return fns()->encrypt(info(), ctx
, nbytes
, ptext
, ctext
);
82 chacha20poly1305_finalize(chacha20poly1305_ctx
*ctx
, uint8_t *tag
)
84 return fns()->finalize(info(), ctx
, tag
);
88 chacha20poly1305_decrypt(chacha20poly1305_ctx
*ctx
, size_t nbytes
, const void *ctext
, void *ptext
)
90 return fns()->decrypt(info(), ctx
, nbytes
, ctext
, ptext
);
94 chacha20poly1305_verify(chacha20poly1305_ctx
*ctx
, const uint8_t *tag
)
96 return fns()->verify(info(), ctx
, tag
);