|
| 1 | +/* |
| 2 | + * Diffie-Hellman-Merkle key exchange |
| 3 | + * |
| 4 | + * Copyright The Mbed TLS Contributors |
| 5 | + * SPDX-License-Identifier: Apache-2.0 |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 8 | + * not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + */ |
| 19 | +/* |
| 20 | + * The following sources were referenced in the design of this implementation |
| 21 | + * of the Diffie-Hellman-Merkle algorithm: |
| 22 | + * |
| 23 | + * [1] Handbook of Applied Cryptography - 1997, Chapter 12 |
| 24 | + * Menezes, van Oorschot and Vanstone |
| 25 | + * |
| 26 | + */ |
| 27 | + |
| 28 | +/* Copied from mbed TLS, missing in CryptoCell runtime library */ |
| 29 | + |
| 30 | +#include "common.h" |
| 31 | + |
| 32 | +#if defined(MBEDTLS_DHM_C) && defined(CONFIG_CC3XX_BACKEND) |
| 33 | + |
| 34 | +#include "mbedtls/dhm.h" |
| 35 | +#include "mbedtls/platform_util.h" |
| 36 | +#include "mbedtls/error.h" |
| 37 | + |
| 38 | +#include <string.h> |
| 39 | + |
| 40 | +#if defined(MBEDTLS_PEM_PARSE_C) |
| 41 | +#include "mbedtls/pem.h" |
| 42 | +#endif |
| 43 | + |
| 44 | +#if defined(MBEDTLS_ASN1_PARSE_C) |
| 45 | +#include "mbedtls/asn1.h" |
| 46 | +#endif |
| 47 | + |
| 48 | +#if defined(MBEDTLS_PLATFORM_C) |
| 49 | +#include "mbedtls/platform.h" |
| 50 | +#else |
| 51 | +#include <stdlib.h> |
| 52 | +#include <stdio.h> |
| 53 | +#define mbedtls_printf printf |
| 54 | +#define mbedtls_calloc calloc |
| 55 | +#define mbedtls_free free |
| 56 | +#endif |
| 57 | + |
| 58 | +size_t mbedtls_dhm_get_bitlen( const mbedtls_dhm_context *ctx ) |
| 59 | +{ |
| 60 | + return( mbedtls_mpi_bitlen( &ctx->P ) ); |
| 61 | +} |
| 62 | + |
| 63 | +size_t mbedtls_dhm_get_len( const mbedtls_dhm_context *ctx ) |
| 64 | +{ |
| 65 | + return( mbedtls_mpi_size( &ctx->P ) ); |
| 66 | +} |
| 67 | + |
| 68 | + |
| 69 | +#endif /* defined(MBEDTLS_DHM_C) && defined(CONFIG_CC3XX_BACKEND) */ |
0 commit comments