| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/evp/e_chacha.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /* $OpenBSD: e_chacha.c,v 1.5 2014/08/04 04:16:11 miod Exp $ */ | - | ||||||
| 2 | /* | - | ||||||
| 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | - | ||||||
| 4 | * | - | ||||||
| 5 | * Permission to use, copy, modify, and distribute this software for any | - | ||||||
| 6 | * purpose with or without fee is hereby granted, provided that the above | - | ||||||
| 7 | * copyright notice and this permission notice appear in all copies. | - | ||||||
| 8 | * | - | ||||||
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | - | ||||||
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | - | ||||||
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | - | ||||||
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | - | ||||||
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | - | ||||||
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | - | ||||||
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | - | ||||||
| 16 | */ | - | ||||||
| 17 | - | |||||||
| 18 | #include <openssl/opensslconf.h> | - | ||||||
| 19 | - | |||||||
| 20 | #ifndef OPENSSL_NO_CHACHA | - | ||||||
| 21 | - | |||||||
| 22 | #include <openssl/chacha.h> | - | ||||||
| 23 | #include <openssl/evp.h> | - | ||||||
| 24 | #include <openssl/objects.h> | - | ||||||
| 25 | - | |||||||
| 26 | #include "evp_locl.h" | - | ||||||
| 27 | - | |||||||
| 28 | static int chacha_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | - | ||||||
| 29 | const unsigned char *in, size_t len); | - | ||||||
| 30 | static int chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, | - | ||||||
| 31 | const unsigned char *iv, int enc); | - | ||||||
| 32 | - | |||||||
| 33 | static const EVP_CIPHER chacha20_cipher = { | - | ||||||
| 34 | .nid = NID_chacha20, | - | ||||||
| 35 | .block_size = 1, | - | ||||||
| 36 | .key_len = 32, | - | ||||||
| 37 | .iv_len = 8, | - | ||||||
| 38 | .flags = EVP_CIPH_STREAM_CIPHER, | - | ||||||
| 39 | .init = chacha_init, | - | ||||||
| 40 | .do_cipher = chacha_cipher, | - | ||||||
| 41 | .ctx_size = sizeof(ChaCha_ctx) | - | ||||||
| 42 | }; | - | ||||||
| 43 | - | |||||||
| 44 | const EVP_CIPHER * | - | ||||||
| 45 | EVP_chacha20(void) | - | ||||||
| 46 | { | - | ||||||
| 47 | return (&chacha20_cipher); executed 292 times by 33 tests: return (&chacha20_cipher);Executed by:
| 292 | ||||||
| 48 | } | - | ||||||
| 49 | - | |||||||
| 50 | static int | - | ||||||
| 51 | chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, | - | ||||||
| 52 | const unsigned char *iv, int enc) | - | ||||||
| 53 | { | - | ||||||
| 54 | ChaCha_set_key((ChaCha_ctx *)ctx->cipher_data, key, | - | ||||||
| 55 | EVP_CIPHER_CTX_key_length(ctx) * 8); | - | ||||||
| 56 | if (iv != NULL)
| 0-8 | ||||||
| 57 | ChaCha_set_iv((ChaCha_ctx *)ctx->cipher_data, iv, NULL); executed 8 times by 1 test: ChaCha_set_iv((ChaCha_ctx *)ctx->cipher_data, iv, ((void *)0) );Executed by:
| 8 | ||||||
| 58 | return 1; executed 8 times by 1 test: return 1;Executed by:
| 8 | ||||||
| 59 | } | - | ||||||
| 60 | - | |||||||
| 61 | static int | - | ||||||
| 62 | chacha_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, | - | ||||||
| 63 | size_t len) | - | ||||||
| 64 | { | - | ||||||
| 65 | ChaCha((ChaCha_ctx *)ctx->cipher_data, out, in, len); | - | ||||||
| 66 | return 1; executed 8 times by 1 test: return 1;Executed by:
| 8 | ||||||
| 67 | } | - | ||||||
| 68 | - | |||||||
| 69 | #endif | - | ||||||
| Source code | Switch to Preprocessed file |