mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.0 KiB
C
77 lines
2.0 KiB
C
4 years ago
|
/**
|
||
6 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
6 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
6 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
6 years ago
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_SSL_H
|
||
|
#define SRSRAN_SSL_H
|
||
8 years ago
|
|
||
|
#ifdef HAVE_POLARSSL
|
||
|
|
||
|
#include "polarssl/aes.h"
|
||
6 years ago
|
#include "polarssl/sha256.h"
|
||
8 years ago
|
|
||
6 years ago
|
void sha256(const unsigned char* key,
|
||
|
size_t keylen,
|
||
|
const unsigned char* input,
|
||
|
size_t ilen,
|
||
|
unsigned char output[32],
|
||
|
int is224)
|
||
8 years ago
|
{
|
||
|
sha256_hmac(key, keylen, input, ilen, output, is224);
|
||
|
}
|
||
|
|
||
|
#endif // HAVE_POLARSSL
|
||
|
|
||
|
#ifdef HAVE_MBEDTLS
|
||
|
|
||
|
#include "mbedtls/aes.h"
|
||
6 years ago
|
#include "mbedtls/md.h"
|
||
8 years ago
|
|
||
|
typedef mbedtls_aes_context aes_context;
|
||
|
|
||
6 years ago
|
#define AES_ENCRYPT 1
|
||
|
#define AES_DECRYPT 0
|
||
8 years ago
|
|
||
6 years ago
|
int aes_setkey_enc(aes_context* ctx, const unsigned char* key, unsigned int keysize)
|
||
8 years ago
|
{
|
||
|
return mbedtls_aes_setkey_enc(ctx, key, keysize);
|
||
|
}
|
||
|
|
||
6 years ago
|
int aes_crypt_ecb(aes_context* ctx, int mode, const unsigned char input[16], unsigned char output[16])
|
||
8 years ago
|
{
|
||
|
return mbedtls_aes_crypt_ecb(ctx, mode, input, output);
|
||
|
}
|
||
|
|
||
6 years ago
|
int aes_crypt_ctr(aes_context* ctx,
|
||
|
size_t length,
|
||
|
size_t* nc_off,
|
||
|
unsigned char nonce_counter[16],
|
||
|
unsigned char stream_block[16],
|
||
|
const unsigned char* input,
|
||
|
unsigned char* output)
|
||
7 years ago
|
{
|
||
6 years ago
|
return mbedtls_aes_crypt_ctr(ctx, length, nc_off, nonce_counter, stream_block, input, output);
|
||
7 years ago
|
}
|
||
|
|
||
6 years ago
|
void sha256(const unsigned char* key,
|
||
|
size_t keylen,
|
||
|
const unsigned char* input,
|
||
|
size_t ilen,
|
||
|
unsigned char output[32],
|
||
|
int is224)
|
||
8 years ago
|
{
|
||
6 years ago
|
mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), key, keylen, input, ilen, output);
|
||
8 years ago
|
}
|
||
|
|
||
|
#endif // HAVE_MBEDTLS
|
||
|
|
||
4 years ago
|
#endif // SRSRAN_SSL_H
|