Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
76 changes: 53 additions & 23 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ const freetypeSources = [_][]const u8{
const tfPsaCryptoCoreSources: []const []const u8 = &.{
"psa_crypto.c",
"psa_crypto_client.c",
"psa_crypto_random.c",
"psa_crypto_slot_management.c",
"psa_crypto_storage.c",
"psa_its_file.c",
"psa_util.c",
"tf_psa_crypto_config.c",
"tf_psa_crypto_version.c",
};
Expand All @@ -99,9 +101,6 @@ const tfPsaCryptoDriverSources: []const []const u8 = &.{
"aesce.c",
"aesni.c",
"aria.c",
"asn1parse.c",
"asn1write.c",
"base64.c",
"bignum.c",
"bignum_core.c",
"bignum_mod.c",
Expand All @@ -110,39 +109,21 @@ const tfPsaCryptoDriverSources: []const []const u8 = &.{
"camellia.c",
"ccm.c",
"chacha20.c",
"chacha20_neon.c",
"chachapoly.c",
"cipher.c",
"cipher_wrap.c",
"cmac.c",
"constant_time.c",
"ctr_drbg.c",
"ecdh.c",
"ecdsa.c",
"ecjpake.c",
"ecp.c",
"ecp_curves.c",
"ecp_curves_new.c",
"entropy.c",
"entropy_poll.c",
"gcm.c",
"hmac_drbg.c",
"lmots.c",
"lms.c",
"md.c",
"md5.c",
"memory_buffer_alloc.c",
"nist_kw.c",
"oid.c",
"pem.c",
"pk.c",
"pk_ecc.c",
"pk_rsa.c",
"pk_wrap.c",
"pkcs5.c",
"pkparse.c",
"pkwrite.c",
"platform.c",
"platform_util.c",
"poly1305.c",
"psa_crypto_aead.c",
"psa_crypto_cipher.c",
Expand All @@ -152,17 +133,47 @@ const tfPsaCryptoDriverSources: []const []const u8 = &.{
"psa_crypto_mac.c",
"psa_crypto_pake.c",
"psa_crypto_rsa.c",
"psa_util.c",
"psa_crypto_xof.c",
"psa_util_internal.c",
"ripemd160.c",
"rsa.c",
"rsa_alt_helpers.c",
"sha1.c",
"sha256.c",
"sha3.c",
"sha512.c",
};

const tfPsaCryptoExtraSources: []const []const u8 = &.{
"lmots.c",
"lms.c",
"md.c",
"nist_kw.c",
"pk.c",
"pk_ecc.c",
"pk_rsa.c",
"pk_wrap.c",
"pkparse.c",
"pkwrite.c",
};

const tfPsaCryptoPlatformSources: []const []const u8 = &.{
"memory_buffer_alloc.c",
"platform.c",
"platform_util.c",
"threading.c",
};

const tfPsaCryptoUtilitySources: []const []const u8 = &.{
"asn1parse.c",
"asn1write.c",
"base64.c",
"constant_time.c",
"oid.c",
"pem.c",
"pkcs5.c",
};

const mbedTlsSources: []const []const u8 = &.{
"mbedtls_config.c",
"pkcs7.c",
Expand Down Expand Up @@ -714,6 +725,21 @@ pub fn addMbedTls(b: *std.Build, c_lib: *std.Build.Step.Compile, flags: []const
.files = tfPsaCryptoDriverSources,
.flags = flags,
});
c_lib.root_module.addCSourceFiles(.{
.root = tfPsaCrypto.path("extras"),
.files = tfPsaCryptoExtraSources,
.flags = flags,
});
c_lib.root_module.addCSourceFiles(.{
.root = tfPsaCrypto.path("platform"),
.files = tfPsaCryptoPlatformSources,
.flags = flags,
});
c_lib.root_module.addCSourceFiles(.{
.root = tfPsaCrypto.path("utilities"),
.files = tfPsaCryptoUtilitySources,
.flags = flags,
});
c_lib.root_module.addCSourceFile(.{
.file = b.path("lib/tf_psa_crypto/psa_crypto_driver_wrappers_no_static.c"), // Generated file
.flags = flags,
Expand All @@ -727,9 +753,13 @@ pub fn addMbedTls(b: *std.Build, c_lib: *std.Build.Step.Compile, flags: []const
c_lib.root_module.addIncludePath(b.path("lib/mbedtls")); // Contains generated files
c_lib.root_module.addIncludePath(tfPsaCrypto.path("core"));
c_lib.root_module.addIncludePath(tfPsaCrypto.path("drivers/builtin/src"));
c_lib.root_module.addIncludePath(tfPsaCrypto.path("extras"));
c_lib.root_module.addIncludePath(tfPsaCrypto.path("platform"));
c_lib.root_module.addIncludePath(tfPsaCrypto.path("utilities"));
c_lib.root_module.addIncludePath(tfPsaCrypto.path("include"));
c_lib.root_module.addIncludePath(tfPsaCrypto.path("drivers/builtin/include"));
c_lib.root_module.addIncludePath(mbedtls.path("include"));
c_lib.root_module.addIncludePath(mbedtls.path("library"));
c_lib.installHeadersDirectory(mbedtls.path("include"), "", .{});
c_lib.installHeadersDirectory(tfPsaCrypto.path("include"), "", .{});
c_lib.installHeadersDirectory(tfPsaCrypto.path("drivers/builtin/include"), "", .{});
Expand Down
8 changes: 4 additions & 4 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
.hash = "N-V-__8AAPu4vwC_P5AHlL_kEON58uGgrDcJSjGq9Hc5yadh",
},
.mbedtls = .{
.url = "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-4.0.0.tar.gz",
.hash = "N-V-__8AAKIwiADtY89ifMh8C6X0PHvyBULclU19OYMsiDg_",
.url = "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-4.2.0.tar.gz",
.hash = "N-V-__8AAJhTfgBPRDWtgTyDyZti3tWUN0LHXW3ZIPsN1Ye2",
},
.tf_psa_crypto = .{
.url = "https://github.com/Mbed-TLS/TF-PSA-Crypto/archive/refs/tags/tf-psa-crypto-1.0.0.tar.gz",
.hash = "N-V-__8AAOuqOgGAlxfU32chMWurMwBPZACZk-9MdknRMDIM",
.url = "https://github.com/Mbed-TLS/TF-PSA-Crypto/archive/refs/tags/tf-psa-crypto-1.2.0.tar.gz",
.hash = "N-V-__8AAErdYAGS61CAz9AxQqB_tgHGld7kzql7ImHiDkj-",
},
.stb = .{
.url = "https://github.com/nothings/stb/archive/31c1ad37456438565541f4919958214b6e762fb4.tar.gz",
Expand Down
115 changes: 0 additions & 115 deletions lib/mbedtls/debug_internal.h

This file was deleted.

10 changes: 3 additions & 7 deletions lib/mbedtls/error.c

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use the tar.bz2 release file? I think it does contain the other random files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried but this still happens:
ziglang/zig#26050

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

alright, then honestly I don't think it's really worth updating this library yet as it contains a lot of changed files I'd have to manually verify.
This library was just added earlier this year, so the current version is also quite fresh, and I don't think it's worth the effort.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
/* -*-c-*-
* Error message information
*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/

#include "tf_psa_crypto_common.h"
#include "mbedtls_common.h"

#include "mbedtls/error.h"

Expand Down Expand Up @@ -253,7 +253,7 @@ static const char *mbedtls_high_level_strerr(int error_code)
return( "X509 - Read/write of file failed" );
case -(MBEDTLS_ERR_X509_FATAL_ERROR):
return( "X509 - A fatal error occurred, eg the chain is too long or the vrfy callback failed" );
#endif /* MBEDTLS_X509_USE_C ||
#endif /* MBEDTLS_X509_USE_C ||
MBEDTLS_X509_CREATE_C */

#if defined(MBEDTLS_CIPHER_C)
Expand All @@ -266,10 +266,6 @@ static const char *mbedtls_high_level_strerr(int error_code)
#endif /* MBEDTLS_CIPHER_C */

#if defined(MBEDTLS_ECP_C)
case -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE):
return( "ECP - The requested feature is not available, for example, the requested curve is not supported" );
case -(MBEDTLS_ERR_ECP_RANDOM_FAILED):
return( "ECP - Generation of random value, such as ephemeral key, failed" );
case -(MBEDTLS_ERR_ECP_INVALID_KEY):
return( "ECP - Invalid private or public key" );
#endif /* MBEDTLS_ECP_C */
Expand Down
Loading
Loading