Skip to content

Commit f1ace37

Browse files
yanghuataoxiaoxiang781216
authored andcommitted
apps/crypto: Add project openssl_mbedtls_wrapper
Add openssl mbedtls wrapper project Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
1 parent da83750 commit f1ace37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4330
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config OPENSSL_MBEDTLS_WRAPPER
7+
depends on CRYPTO_MBEDTLS
8+
bool "openssl mbedtls wrapper"
9+
default n
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/crypto/openssl_mbedtls_wrapper/Make.defs
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. 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. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
ifneq ($(CONFIG_OPENSSL_MBEDTLS_WRAPPER),)
22+
CONFIGURED_APPS += $(APPDIR)/crypto/openssl_mbedtls_wrapper
23+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/crypto/openssl_mbedtls_wrapper/include
24+
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/crypto/openssl_mbedtls_wrapper/include
25+
endif
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
############################################################################
2+
# apps/crypto/openssl_mbedtls_wrapper/Makefile
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership. The
7+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance with the
9+
# License. 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. See the
16+
# License for the specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
############################################################################
20+
21+
include $(APPDIR)/Make.defs
22+
CSRCS += $(wildcard $(APPDIR)/crypto/openssl_mbedtls_wrapper/mbedtls/*.c)
23+
include $(APPDIR)/Application.mk
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/****************************************************************************
2+
* apps/crypto/openssl_mbedtls_wrapper/include/openssl/aes.h
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. 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. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
****************************************************************************/
19+
20+
#ifndef OPENSSL_MBEDTLS_WRAPPER_AES_H
21+
#define OPENSSL_MBEDTLS_WRAPPER_AES_H
22+
23+
/****************************************************************************
24+
* Included Files
25+
****************************************************************************/
26+
27+
#include <openssl/base.h>
28+
29+
/****************************************************************************
30+
* Pre-processor Definitions
31+
****************************************************************************/
32+
33+
#define AES_ENCRYPT 1
34+
#define AES_DECRYPT 0
35+
36+
#define AES_BLOCK_SIZE 16
37+
#define AES_MAXNR 14
38+
39+
#ifdef __cplusplus
40+
extern "C"
41+
{
42+
#endif
43+
44+
/****************************************************************************
45+
* Public Types
46+
****************************************************************************/
47+
48+
struct aes_key_st
49+
{
50+
uint32_t rd_key[4 * (AES_MAXNR + 1)];
51+
unsigned rounds;
52+
};
53+
54+
typedef struct aes_key_st AES_KEY;
55+
56+
/****************************************************************************
57+
* Public Function Prototypes
58+
****************************************************************************/
59+
60+
int AES_set_encrypt_key(const uint8_t *key, unsigned bits,
61+
AES_KEY *aeskey);
62+
63+
void AES_encrypt(const uint8_t *in, uint8_t *out,
64+
const AES_KEY *key);
65+
66+
int AES_set_decrypt_key(const uint8_t *key, unsigned bits,
67+
AES_KEY *aeskey);
68+
69+
void AES_decrypt(const uint8_t *in, uint8_t *out,
70+
const AES_KEY *key);
71+
72+
void AES_cbc_encrypt(const uint8_t *in, uint8_t *out,
73+
size_t len, const AES_KEY *key,
74+
uint8_t *ivec, const int enc);
75+
76+
#ifdef __cplusplus
77+
}
78+
#endif
79+
80+
#endif /* OPENSSL_MBEDTLS_WRAPPER_AES_H */
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/****************************************************************************
2+
* apps/crypto/openssl_mbedtls_wrapper/include/openssl/asn1.h
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. 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. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
****************************************************************************/
19+
20+
#ifndef OPENSSL_MBEDTLS_WRAPPER_ASN1_H
21+
#define OPENSSL_MBEDTLS_WRAPPER_ASN1_H
22+
23+
/****************************************************************************
24+
* Included Files
25+
****************************************************************************/
26+
27+
#include <openssl/base.h>
28+
#include <time.h>
29+
30+
/****************************************************************************
31+
* Pre-processor Definitions
32+
****************************************************************************/
33+
34+
#define MBSTRING_FLAG 0x1000
35+
#define MBSTRING_UTF8 (MBSTRING_FLAG)
36+
#define MBSTRING_ASC (MBSTRING_FLAG | 1)
37+
38+
#define V_ASN1_NULL 5
39+
40+
#ifdef __cplusplus
41+
extern "C"
42+
{
43+
#endif
44+
45+
/****************************************************************************
46+
* Public Function Prototypes
47+
****************************************************************************/
48+
49+
void ASN1_BIT_STRING_free(ASN1_BIT_STRING *a);
50+
51+
void ASN1_INTEGER_free(ASN1_INTEGER *a);
52+
53+
void ASN1_OBJECT_free(ASN1_OBJECT *a);
54+
55+
void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *a);
56+
57+
void ASN1_TIME_free(ASN1_TIME *a);
58+
59+
ASN1_BIT_STRING *ASN1_BIT_STRING_new(void);
60+
61+
int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *str, int n, int value);
62+
63+
ASN1_OCTET_STRING *ASN1_OCTET_STRING_new(void);
64+
65+
int i2d_ASN1_BIT_STRING(const ASN1_BIT_STRING *in, uint8_t **outp);
66+
67+
int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str,
68+
const unsigned char *data, int len);
69+
70+
ASN1_INTEGER *ASN1_INTEGER_new(void);
71+
72+
ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
73+
74+
ASN1_TIME *ASN1_TIME_new(void);
75+
76+
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);
77+
78+
#ifdef __cplusplus
79+
}
80+
#endif
81+
82+
#endif /* OPENSSL_MBEDTLS_WRAPPER_ASN1_H */
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/****************************************************************************
2+
* apps/crypto/openssl_mbedtls_wrapper/include/openssl/base.h
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. 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. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
****************************************************************************/
19+
20+
#ifndef OPENSSL_MBEDTLS_WRAPPER_BASE_H
21+
#define OPENSSL_MBEDTLS_WRAPPER_BASE_H
22+
23+
/****************************************************************************
24+
* Included Files
25+
****************************************************************************/
26+
27+
#include <stddef.h>
28+
#include <stdint.h>
29+
#include <sys/types.h>
30+
31+
/****************************************************************************
32+
* Pre-processor Definitions
33+
****************************************************************************/
34+
35+
#define ASN1_BIT_STRING ASN1_STRING
36+
37+
#ifdef __cplusplus
38+
extern "C"
39+
{
40+
#endif
41+
42+
/****************************************************************************
43+
* Public Types
44+
****************************************************************************/
45+
46+
typedef struct EVP_CIPHER EVP_CIPHER;
47+
typedef struct EVP_CIPHER_CTX EVP_CIPHER_CTX;
48+
typedef struct ENGINE ENGINE;
49+
typedef struct EVP_MD EVP_MD;
50+
typedef struct EVP_MD_CTX EVP_MD_CTX;
51+
typedef struct ASN1_BIT_STRING ASN1_BIT_STRING;
52+
typedef struct ASN1_INTEGER ASN1_INTEGER;
53+
typedef struct ASN1_OBJECT ASN1_OBJECT;
54+
typedef struct ASN1_OCTET_STRING ASN1_OCTET_STRING;
55+
typedef struct ASN1_TIME ASN1_TIME;
56+
typedef struct BN_CTX BN_CTX;
57+
typedef struct EC_GROUP EC_GROUP;
58+
typedef struct EC_KEY EC_KEY;
59+
typedef struct EC_POINT EC_POINT;
60+
typedef struct EVP_PKEY EVP_PKEY;
61+
typedef struct EVP_PKEY_CTX EVP_PKEY_CTX;
62+
typedef struct PKCS8_PRIV_KEY_INFO PKCS8_PRIV_KEY_INFO;
63+
typedef struct RSA RSA;
64+
typedef struct X509 X509;
65+
typedef struct X509_ALGOR X509_ALGOR;
66+
typedef struct X509_EXTENSION X509_EXTENSION;
67+
typedef struct X509_NAME X509_NAME;
68+
typedef struct BIGNUM BIGNUM;
69+
typedef struct HMAC_CTX HMAC_CTX;
70+
typedef struct rsa_meth_st RSA_METHOD;
71+
typedef struct ecdsa_method_st ECDSA_METHOD;
72+
typedef struct BN_GENCB BN_GENCB;
73+
typedef struct sha256_state_st SHA256_CTX;
74+
typedef struct sha_state_st SHA_CTX;
75+
typedef struct cbb_st CBB;
76+
typedef struct ecdsa_sig_st ECDSA_SIG;
77+
78+
#ifdef __cplusplus
79+
}
80+
#endif
81+
82+
#endif /* OPENSSL_MBEDTLS_WRAPPER_BASE_H */
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/****************************************************************************
2+
* apps/crypto/openssl_mbedtls_wrapper/include/openssl/bio.h
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership. The
7+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance with the
9+
* License. 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. See the
16+
* License for the specific language governing permissions and limitations
17+
* under the License.
18+
****************************************************************************/
19+
20+
#ifndef OPENSSL_MBEDTLS_WRAPPER_BIO_H
21+
#define OPENSSL_MBEDTLS_WRAPPER_BIO_H
22+
23+
/****************************************************************************
24+
* Included Files
25+
****************************************************************************/
26+
27+
#include <openssl/base.h>
28+
29+
/****************************************************************************
30+
* Public Function Prototypes
31+
****************************************************************************/
32+
33+
#ifdef __cplusplus
34+
extern "C"
35+
{
36+
#endif
37+
38+
#ifdef __cplusplus
39+
}
40+
#endif
41+
42+
#endif /* OPENSSL_MBEDTLS_WRAPPER_BIO_H */

0 commit comments

Comments
 (0)