Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ada Bindings for wolfSSL #6605

Merged
merged 6 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/configs/user_settings_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ extern "C" {
#define WOLFSSL_DER_TO_PEM
#define WOLFSSL_CUSTOM_OID
#define HAVE_OID_ENCODING
//#define WOLFSSL_ASN_TEMPLATE /* Not enabled yet by default */
#define WOLFSSL_ASN_TEMPLATE

/* Certificate Revocation */
#define HAVE_OCSP
Expand Down
4 changes: 2 additions & 2 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -30648,9 +30648,9 @@ int wc_SetCustomExtension(Cert *cert, int critical, const char *oid,

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

ext->oid = oid;
ext->oid = (char*)oid;
ext->crit = (critical == 0) ? 0 : 1;
ext->val = der;
ext->val = (byte*)der;
ext->valSz = derSz;

cert->customCertExtCount++;
Expand Down
22 changes: 22 additions & 0 deletions wrapper/Ada/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Ada Binding Example

Download and install the GNAT community edition compiler and studio:
https://www.adacore.com/download

Linux Install:

```sh
chmod +x gnat-2021-20210519-x86_64-linux-bin
./gnat-2021-20210519-x86_64-linux-bin
```

```sh
export PATH="/opt/GNAT/2021/bin:$PATH"
JacobBarthelmeh marked this conversation as resolved.
Show resolved Hide resolved
gprclean
gprbuild default.gpr
JacobBarthelmeh marked this conversation as resolved.
Show resolved Hide resolved


./c_tls_server_main
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joakim-strandberg can you expand this section and update with latest steps? Perhaps also add some information about Ada and advantages for using?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

./tls_server_main &
./c_tls_client_main 127.0.0.1
```
86 changes: 86 additions & 0 deletions wrapper/Ada/ada_binding.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* ada_binding.c
*
* Copyright (C) 2006-2023 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/

/* wolfSSL */
#include <wolfssl/wolfcrypt/settings.h>

#include <wolfssl/ssl.h>

/* These functions give access to the integer values of the enumeration
constants used in WolfSSL. These functions make it possible
for the WolfSSL implementation to change the values of the constants
without the need to make a corresponding change in the Ada code. */
extern int get_wolfssl_success(void);
extern int get_wolfssl_verify_none(void);
extern int get_wolfssl_verify_peer(void);
extern int get_wolfssl_verify_fail_if_no_peer_cert(void);
extern int get_wolfssl_verify_client_once(void);
extern int get_wolfssl_verify_post_handshake(void);
extern int get_wolfssl_verify_fail_except_psk(void);
extern int get_wolfssl_verify_default(void);

extern int get_wolfssl_filetype_asn1(void);
extern int get_wolfssl_filetype_pem(void);
extern int get_wolfssl_filetype_default(void);

extern int get_wolfssl_success(void) {
return WOLFSSL_SUCCESS;
}

extern int get_wolfssl_verify_none(void) {
return WOLFSSL_VERIFY_NONE;
}

extern int get_wolfssl_verify_peer(void) {
return WOLFSSL_VERIFY_PEER;
}

extern int get_wolfssl_verify_fail_if_no_peer_cert(void) {
return WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT;
}

extern int get_wolfssl_verify_client_once(void) {
return WOLFSSL_VERIFY_CLIENT_ONCE;
}

extern int get_wolfssl_verify_post_handshake(void) {
return WOLFSSL_VERIFY_POST_HANDSHAKE;
}

extern int get_wolfssl_verify_fail_except_psk(void) {
return WOLFSSL_VERIFY_FAIL_EXCEPT_PSK;
}

extern int get_wolfssl_verify_default(void) {
return WOLFSSL_VERIFY_DEFAULT;
}

extern int get_wolfssl_filetype_asn1(void) {
return WOLFSSL_FILETYPE_ASN1;
}

extern int get_wolfssl_filetype_pem(void) {
return WOLFSSL_FILETYPE_PEM;
}

extern int get_wolfssl_filetype_default(void) {
return WOLFSSL_FILETYPE_DEFAULT;
}
Loading