diff options
Diffstat (limited to 'third_party/boringssl/include')
-rw-r--r-- | third_party/boringssl/include/aes-gcm.h | 147 | ||||
-rw-r--r-- | third_party/boringssl/include/aes.h | 129 | ||||
-rw-r--r-- | third_party/boringssl/include/curve25519.h | 70 |
3 files changed, 0 insertions, 346 deletions
diff --git a/third_party/boringssl/include/aes-gcm.h b/third_party/boringssl/include/aes-gcm.h deleted file mode 100644 index e3ef457224..0000000000 --- a/third_party/boringssl/include/aes-gcm.h +++ /dev/null @@ -1,147 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2008 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== */ - -#ifndef __CROS_EC_AES_GCM_H -#define __CROS_EC_AES_GCM_H - -#include "common.h" -#include "endian.h" -#include "util.h" - -// block128_f is the type of a 128-bit, block cipher. -typedef void (*block128_f)(const uint8_t in[16], uint8_t out[16], - const void *key); - -// GCM definitions -typedef struct { uint64_t hi,lo; } u128; - -// gmult_func multiplies |Xi| by the GCM key and writes the result back to -// |Xi|. -typedef void (*gmult_func)(uint64_t Xi[2], const u128 Htable[16]); - -// ghash_func repeatedly multiplies |Xi| by the GCM key and adds in blocks from -// |inp|. The result is written back to |Xi| and the |len| argument must be a -// multiple of 16. -typedef void (*ghash_func)(uint64_t Xi[2], const u128 Htable[16], - const uint8_t *inp, size_t len); - -// This differs from upstream's |gcm128_context| in that it does not have the -// |key| pointer, in order to make it |memcpy|-friendly. Rather the key is -// passed into each call that needs it. -struct gcm128_context { - // Following 6 names follow names in GCM specification - union { - uint64_t u[2]; - uint32_t d[4]; - uint8_t c[16]; - size_t t[16 / sizeof(size_t)]; - } Yi, EKi, EK0, len, Xi; - - // Note that the order of |Xi|, |H| and |Htable| is fixed by the MOVBE-based, - // x86-64, GHASH assembly. - u128 H; - u128 Htable[16]; - gmult_func gmult; - ghash_func ghash; - - unsigned int mres, ares; - block128_f block; -}; - - -// GCM. -// -// This API differs from the upstream API slightly. The |GCM128_CONTEXT| does -// not have a |key| pointer that points to the key as upstream's version does. -// Instead, every function takes a |key| parameter. This way |GCM128_CONTEXT| -// can be safely copied. - -typedef struct gcm128_context GCM128_CONTEXT; - -// CRYPTO_gcm128_init initialises |ctx| to use |block| (typically AES) with -// the given key. |block_is_hwaes| is one if |block| is |aes_hw_encrypt|. -void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, const void *key, - block128_f block, int block_is_hwaes); - -// CRYPTO_gcm128_setiv sets the IV (nonce) for |ctx|. The |key| must be the -// same key that was passed to |CRYPTO_gcm128_init|. -void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const void *key, - const uint8_t *iv, size_t iv_len); - -// CRYPTO_gcm128_aad sets the authenticated data for an instance of GCM. -// This must be called before and data is encrypted. It returns one on success -// and zero otherwise. -int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const uint8_t *aad, - size_t len); - -// CRYPTO_gcm128_encrypt encrypts |len| bytes from |in| to |out|. The |key| -// must be the same key that was passed to |CRYPTO_gcm128_init|. It returns one -// on success and zero otherwise. -int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const void *key, - const uint8_t *in, uint8_t *out, - size_t len); - -// CRYPTO_gcm128_decrypt decrypts |len| bytes from |in| to |out|. The |key| -// must be the same key that was passed to |CRYPTO_gcm128_init|. It returns one -// on success and zero otherwise. -int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const void *key, - const uint8_t *in, uint8_t *out, - size_t len); - -// CRYPTO_gcm128_finish calculates the authenticator and compares it against -// |len| bytes of |tag|. It returns one on success and zero otherwise. -int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const uint8_t *tag, - size_t len); - -// CRYPTO_gcm128_tag calculates the authenticator and copies it into |tag|. -// The minimum of |len| and 16 bytes are copied into |tag|. -void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, uint8_t *tag, - size_t len); - - -#endif // __CROS_EC_AES_GCM_H diff --git a/third_party/boringssl/include/aes.h b/third_party/boringssl/include/aes.h deleted file mode 100644 index 6418a350eb..0000000000 --- a/third_party/boringssl/include/aes.h +++ /dev/null @@ -1,129 +0,0 @@ -/* ==================================================================== - * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== */ - -#ifndef __CROS_EC_AES_H -#define __CROS_EC_AES_H - -#include <stdint.h> - -#define AES_ENCRYPT 1 -#define AES_DECRYPT 0 - -/* AES_MAXNR is the maximum number of AES rounds. */ -#define AES_MAXNR 14 - -#define AES_BLOCK_SIZE 16 - -/* - * aes_key_st should be an opaque type, but EVP requires that the size be - * known. - */ -struct aes_key_st { - uint32_t rd_key[4 * (AES_MAXNR + 1)]; - unsigned rounds; -}; -typedef struct aes_key_st AES_KEY; - -/* - * These functions are provided by either common/aes.c, or assembly code, - * and should not be called directly. - */ -void aes_nohw_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key); -void aes_nohw_decrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key); -int aes_nohw_set_encrypt_key(const uint8_t *key, unsigned bits, - AES_KEY *aeskey); -int aes_nohw_set_decrypt_key(const uint8_t *key, unsigned bits, - AES_KEY *aeskey); - -/** - * AES_set_encrypt_key configures |aeskey| to encrypt with the |bits|-bit key, - * |key|. - * - * WARNING: unlike other OpenSSL functions, this returns zero on success and a - * negative number on error. - */ -static inline int AES_set_encrypt_key(const uint8_t *key, unsigned int bits, - AES_KEY *aeskey) -{ - return aes_nohw_set_encrypt_key(key, bits, aeskey); -} - -/** - * AES_set_decrypt_key configures |aeskey| to decrypt with the |bits|-bit key, - * |key|. - * - * WARNING: unlike other OpenSSL functions, this returns zero on success and a - * negative number on error. - */ -static inline int AES_set_decrypt_key(const uint8_t *key, unsigned int bits, - AES_KEY *aeskey) -{ - return aes_nohw_set_decrypt_key(key, bits, aeskey); -} - -/** - * AES_encrypt encrypts a single block from |in| to |out| with |key|. The |in| - * and |out| pointers may overlap. - */ -static inline void AES_encrypt(const uint8_t *in, uint8_t *out, - const AES_KEY *key) -{ - aes_nohw_encrypt(in, out, key); -} - -/** - * AES_decrypt decrypts a single block from |in| to |out| with |key|. The |in| - * and |out| pointers may overlap. - */ -static inline void AES_decrypt(const uint8_t *in, uint8_t *out, - const AES_KEY *key) -{ - aes_nohw_decrypt(in, out, key); -} - -#endif /* __CROS_EC_AES_H */ diff --git a/third_party/boringssl/include/curve25519.h b/third_party/boringssl/include/curve25519.h deleted file mode 100644 index 8287c94466..0000000000 --- a/third_party/boringssl/include/curve25519.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __CROS_EC_CURVE25519_H -#define __CROS_EC_CURVE25519_H - -#include <stdint.h> - -/* Curve25519. - * - * Curve25519 is an elliptic curve. See https://tools.ietf.org/html/rfc7748. - */ - - -/* X25519. - * - * X25519 is the Diffie-Hellman primitive built from curve25519. It is - * sometimes referred to as “curve25519”, but “X25519” is a more precise - * name. - * See http://cr.yp.to/ecdh.html and https://tools.ietf.org/html/rfc7748. - */ - -#define X25519_PRIVATE_KEY_LEN 32 -#define X25519_PUBLIC_VALUE_LEN 32 - -/** - * Generate a public/private key pair. - * @param out_public_value generated public key. - * @param out_private_value generated private key. - */ -void X25519_keypair(uint8_t out_public_value[32], uint8_t out_private_key[32]); - -/** - * Diffie-Hellman function. - * @param out_shared_key - * @param private_key - * @param out_public_value - * @return one on success and zero on error. - * - * X25519() writes a shared key to @out_shared_key that is calculated from the - * given private key and the peer's public value. - * - * Don't use the shared key directly, rather use a KDF and also include the two - * public values as inputs. - */ -int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32], - const uint8_t peers_public_value[32]); - -/** - * Compute the matching public key. - * @param out_public_value computed public key. - * @param private_key private key to use. - * - * X25519_public_from_private() calculates a Diffie-Hellman public value from - * the given private key and writes it to @out_public_value. - */ -void X25519_public_from_private(uint8_t out_public_value[32], - const uint8_t private_key[32]); - -/* - * Low-level x25519 function, defined by either the generic or cortex-m0 - * implementation. Must not be called directly. - */ -void x25519_scalar_mult(uint8_t out[32], - const uint8_t scalar[32], - const uint8_t point[32]); - -#endif /* __CROS_EC_CURVE25519_H */ |