Skip to content

Commit d20a096

Browse files
committed
Ada Bindings for wolfSSL. Credit Joakim Dahlgren Strandberg <joakimds@kth.se>
1 parent b8119af commit d20a096

19 files changed

Lines changed: 2438 additions & 3 deletions

examples/configs/user_settings_all.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ extern "C" {
125125
#define WOLFSSL_DER_TO_PEM
126126
#define WOLFSSL_CUSTOM_OID
127127
#define HAVE_OID_ENCODING
128-
//#define WOLFSSL_ASN_TEMPLATE /* Not enabled yet by default */
128+
#define WOLFSSL_ASN_TEMPLATE
129129

130130
/* Certificate Revocation */
131131
#define HAVE_OCSP

wolfcrypt/src/asn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30648,9 +30648,9 @@ int wc_SetCustomExtension(Cert *cert, int critical, const char *oid,
3064830648

3064930649
ext = &cert->customCertExt[cert->customCertExtCount];
3065030650

30651-
ext->oid = oid;
30651+
ext->oid = (char*)oid;
3065230652
ext->crit = (critical == 0) ? 0 : 1;
30653-
ext->val = der;
30653+
ext->val = (byte*)der;
3065430654
ext->valSz = derSz;
3065530655

3065630656
cert->customCertExtCount++;

wrapper/Ada/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Ada Binding Example
2+
3+
Download and install the GNAT community edition compiler and studio:
4+
https://www.adacore.com/download
5+
6+
Linux Install:
7+
8+
```sh
9+
chmod +x gnat-2021-20210519-x86_64-linux-bin
10+
./gnat-2021-20210519-x86_64-linux-bin
11+
```
12+
13+
```sh
14+
export PATH="/opt/GNAT/2021/bin:$PATH"
15+
gprclean
16+
gprbuild default.gpr
17+
18+
19+
./c_tls_server_main
20+
./tls_server_main &
21+
./c_tls_client_main 127.0.0.1
22+
```

wrapper/Ada/ada_binding.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* ada_binding.c
2+
*
3+
* Copyright (C) 2006-2023 wolfSSL Inc.
4+
*
5+
* This file is part of wolfSSL.
6+
*
7+
* wolfSSL is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfSSL is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
22+
/* wolfSSL */
23+
#include <wolfssl/wolfcrypt/settings.h>
24+
25+
#include <wolfssl/ssl.h>
26+
27+
// These functions give access to the integer values of the enumeration
28+
// constants used in WolfSSL. These functions make it possible
29+
// for the WolfSSL implementation to change the values of the constants
30+
// without the need to make a corresponding change in the Ada code.
31+
extern int get_wolfssl_success(void);
32+
extern int get_wolfssl_verify_none(void);
33+
extern int get_wolfssl_verify_peer(void);
34+
extern int get_wolfssl_verify_fail_if_no_peer_cert(void);
35+
extern int get_wolfssl_verify_client_once(void);
36+
extern int get_wolfssl_verify_post_handshake(void);
37+
extern int get_wolfssl_verify_fail_except_psk(void);
38+
extern int get_wolfssl_verify_default(void);
39+
40+
extern int get_wolfssl_filetype_asn1(void);
41+
extern int get_wolfssl_filetype_pem(void);
42+
extern int get_wolfssl_filetype_default(void);
43+
44+
extern int get_wolfssl_success(void) {
45+
return WOLFSSL_SUCCESS;
46+
}
47+
48+
extern int get_wolfssl_verify_none(void) {
49+
return WOLFSSL_VERIFY_NONE;
50+
}
51+
52+
extern int get_wolfssl_verify_peer(void) {
53+
return WOLFSSL_VERIFY_PEER;
54+
}
55+
56+
extern int get_wolfssl_verify_fail_if_no_peer_cert(void) {
57+
return WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT;
58+
}
59+
60+
extern int get_wolfssl_verify_client_once(void) {
61+
return WOLFSSL_VERIFY_CLIENT_ONCE;
62+
}
63+
64+
extern int get_wolfssl_verify_post_handshake(void) {
65+
return WOLFSSL_VERIFY_POST_HANDSHAKE;
66+
}
67+
68+
extern int get_wolfssl_verify_fail_except_psk(void) {
69+
return WOLFSSL_VERIFY_FAIL_EXCEPT_PSK;
70+
}
71+
72+
extern int get_wolfssl_verify_default(void) {
73+
return WOLFSSL_VERIFY_DEFAULT;
74+
}
75+
76+
extern int get_wolfssl_filetype_asn1(void) {
77+
return WOLFSSL_FILETYPE_ASN1;
78+
}
79+
80+
extern int get_wolfssl_filetype_pem(void) {
81+
return WOLFSSL_FILETYPE_PEM;
82+
}
83+
84+
extern int get_wolfssl_filetype_default(void) {
85+
return WOLFSSL_FILETYPE_DEFAULT;
86+
}

0 commit comments

Comments
 (0)