]>
Commit | Line | Data |
---|---|---|
5ba3f43e A |
1 | /* |
2 | * Copyright (c) 2017 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
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. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
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. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | ||
29 | #include <corecrypto/ccchacha20poly1305.h> | |
30 | #include <libkern/crypto/crypto_internal.h> | |
31 | #include <libkern/crypto/chacha20poly1305.h> | |
32 | ||
33 | static ccchacha20poly1305_fns_t fns(void) | |
34 | { | |
35 | return g_crypto_funcs->ccchacha20poly1305_fns; | |
36 | } | |
37 | ||
38 | static const struct ccchacha20poly1305_info *info(void) | |
39 | { | |
40 | return fns()->info(); | |
41 | } | |
42 | ||
43 | int chacha20poly1305_init(chacha20poly1305_ctx *ctx, const uint8_t *key) | |
44 | { | |
45 | return fns()->init(info(), ctx, key); | |
46 | } | |
47 | ||
48 | int chacha20poly1305_reset(chacha20poly1305_ctx *ctx) | |
49 | { | |
50 | return fns()->reset(info(), ctx); | |
51 | } | |
52 | ||
53 | int chacha20poly1305_setnonce(chacha20poly1305_ctx *ctx, const uint8_t *nonce) | |
54 | { | |
55 | return fns()->setnonce(info(), ctx, nonce); | |
56 | } | |
57 | ||
58 | int chacha20poly1305_incnonce(chacha20poly1305_ctx *ctx, uint8_t *nonce) | |
59 | { | |
60 | return fns()->incnonce(info(), ctx, nonce); | |
61 | } | |
62 | ||
63 | int chacha20poly1305_aad(chacha20poly1305_ctx *ctx, size_t nbytes, const void *aad) | |
64 | { | |
65 | return fns()->aad(info(), ctx, nbytes, aad); | |
66 | } | |
67 | ||
68 | int chacha20poly1305_encrypt(chacha20poly1305_ctx *ctx, size_t nbytes, const void *ptext, void *ctext) | |
69 | { | |
70 | return fns()->encrypt(info(), ctx, nbytes, ptext, ctext); | |
71 | } | |
72 | ||
73 | int chacha20poly1305_finalize(chacha20poly1305_ctx *ctx, uint8_t *tag) | |
74 | { | |
75 | return fns()->finalize(info(), ctx, tag); | |
76 | } | |
77 | ||
78 | int chacha20poly1305_decrypt(chacha20poly1305_ctx *ctx, size_t nbytes, const void *ctext, void *ptext) | |
79 | { | |
80 | return fns()->decrypt(info(), ctx, nbytes, ctext, ptext); | |
81 | } | |
82 | ||
83 | int chacha20poly1305_verify(chacha20poly1305_ctx *ctx, const uint8_t *tag) | |
84 | { | |
85 | return fns()->verify(info(), ctx, tag); | |
86 | } |