Skip to content

Commit e4a238b

Browse files
committed
try to get s2n-tls working
1 parent 98948cd commit e4a238b

File tree

2 files changed

+149
-12
lines changed

2 files changed

+149
-12
lines changed

deps/s2n-tls/default.nix

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ let
1111

1212
src = pkgs.fetchzip {
1313
url = "https://github.com/aws/s2n-tls/archive/v${version}.tar.gz";
14-
sha256 = "18qjqc2jrpiwdpzqxl6hl1cq0nfmqk8qas0ijpwr0g606av0aqm9";
14+
sha256 = "18qjqc2jrpiwdpzqxl6hl1cq0nfmqk8qas0ijpwr0g606av0aqm9"; # v0.9.0
15+
# hash = "sha256-aJRw1a/XJivNZS3NkZ4U6nC12+wY/aoNv33mbAzNl0k="; # v1.5.27
1516
};
1617

18+
patches = [ ./fix-strict-prototypes.patch ];
19+
1720
buildInputs = [
1821
pkgs.pkgsStatic.openssl
1922
];
2023

21-
# the default 'all' target depends on tests which are broken (see below)
24+
# ld: cannot find -lgcc_eh: No such file or directory
25+
# ld: have you installed the static version of the gcc_eh library ?
2226
buildPhase = ''
2327
runHook preBuild
2428
@@ -27,17 +31,8 @@ let
2731
runHook postBuild
2832
'';
2933

30-
# TODO: tests fail:
31-
# make -C unit
32-
# make[2]: Entering directory '/build/source/tests/unit'
33-
# Running s2n_3des_test.c ... FAILED test 1
34-
# !((conn = s2n_connection_new(S2N_SERVER)) == (((void *)0))) is not true (s2n_3des_test.c line 44)
35-
# Error Message: 'error calling mlock (Did you run prlimit?)'
36-
# Debug String: 'Error encountered in s2n_mem.c line 103'
37-
# make[2]: *** [Makefile:44: s2n_3des_test] Error 1
38-
doCheck = false;
39-
4034
# Upstream Makefile has no install target
35+
# FIXME: looks like it does now: https://github.com/aws/s2n-tls/blame/73720795dbc37d295592f427e8c225cfafef39a0/Makefile#L106
4136
installPhase = ''
4237
runHook preInstall
4338
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
diff --git a/crypto/s2n_aead_cipher_aes_gcm.c b/crypto/s2n_aead_cipher_aes_gcm.c
2+
index 36820ab20..1c12eb4ed 100644
3+
--- a/crypto/s2n_aead_cipher_aes_gcm.c
4+
+++ b/crypto/s2n_aead_cipher_aes_gcm.c
5+
@@ -23,12 +23,12 @@
6+
#include "utils/s2n_safety.h"
7+
#include "utils/s2n_blob.h"
8+
9+
-static uint8_t s2n_aead_cipher_aes128_gcm_available()
10+
+static uint8_t s2n_aead_cipher_aes128_gcm_available(void)
11+
{
12+
return (EVP_aes_128_gcm() ? 1 : 0);
13+
}
14+
15+
-static uint8_t s2n_aead_cipher_aes256_gcm_available()
16+
+static uint8_t s2n_aead_cipher_aes256_gcm_available(void)
17+
{
18+
return (EVP_aes_256_gcm() ? 1 : 0);
19+
}
20+
diff --git a/crypto/s2n_cbc_cipher_3des.c b/crypto/s2n_cbc_cipher_3des.c
21+
index 0a9aae2ed..3e7cc3227 100644
22+
--- a/crypto/s2n_cbc_cipher_3des.c
23+
+++ b/crypto/s2n_cbc_cipher_3des.c
24+
@@ -23,7 +23,7 @@
25+
#include "utils/s2n_safety.h"
26+
#include "utils/s2n_blob.h"
27+
28+
-static uint8_t s2n_cbc_cipher_3des_available()
29+
+static uint8_t s2n_cbc_cipher_3des_available(void)
30+
{
31+
return (EVP_des_ede3_cbc() ? 1 : 0);
32+
}
33+
diff --git a/crypto/s2n_cbc_cipher_aes.c b/crypto/s2n_cbc_cipher_aes.c
34+
index a504fd103..8818a5f8d 100644
35+
--- a/crypto/s2n_cbc_cipher_aes.c
36+
+++ b/crypto/s2n_cbc_cipher_aes.c
37+
@@ -23,12 +23,12 @@
38+
#include "utils/s2n_safety.h"
39+
#include "utils/s2n_blob.h"
40+
41+
-static uint8_t s2n_cbc_cipher_aes128_available()
42+
+static uint8_t s2n_cbc_cipher_aes128_available(void)
43+
{
44+
return (EVP_aes_128_cbc() ? 1 : 0);
45+
}
46+
47+
-static uint8_t s2n_cbc_cipher_aes256_available()
48+
+static uint8_t s2n_cbc_cipher_aes256_available(void)
49+
{
50+
return (EVP_aes_256_cbc() ? 1 : 0);
51+
}
52+
diff --git a/crypto/s2n_stream_cipher_null.c b/crypto/s2n_stream_cipher_null.c
53+
index 2d2093ca4..5ff3ea6be 100644
54+
--- a/crypto/s2n_stream_cipher_null.c
55+
+++ b/crypto/s2n_stream_cipher_null.c
56+
@@ -20,7 +20,7 @@
57+
#include "utils/s2n_safety.h"
58+
#include "utils/s2n_blob.h"
59+
60+
-static uint8_t s2n_stream_cipher_null_available()
61+
+static uint8_t s2n_stream_cipher_null_available(void)
62+
{
63+
return 1;
64+
}
65+
diff --git a/crypto/s2n_stream_cipher_rc4.c b/crypto/s2n_stream_cipher_rc4.c
66+
index bf94aad7a..8abd3223f 100644
67+
--- a/crypto/s2n_stream_cipher_rc4.c
68+
+++ b/crypto/s2n_stream_cipher_rc4.c
69+
@@ -21,7 +21,7 @@
70+
#include "utils/s2n_safety.h"
71+
#include "utils/s2n_blob.h"
72+
73+
-static uint8_t s2n_stream_cipher_rc4_available()
74+
+static uint8_t s2n_stream_cipher_rc4_available(void)
75+
{
76+
return (EVP_rc4() ? 1 : 0);
77+
}
78+
diff --git a/utils/s2n_map.c b/utils/s2n_map.c
79+
index b76d44057..4d4d78272 100644
80+
--- a/utils/s2n_map.c
81+
+++ b/utils/s2n_map.c
82+
@@ -81,7 +81,7 @@ static int s2n_map_embiggen(struct s2n_map *map, uint32_t capacity)
83+
return 0;
84+
}
85+
86+
-struct s2n_map *s2n_map_new()
87+
+struct s2n_map *s2n_map_new(void)
88+
{
89+
struct s2n_blob mem = {0};
90+
struct s2n_map *map;
91+
diff --git a/utils/s2n_map.h b/utils/s2n_map.h
92+
index abea548f1..25a5a4bab 100644
93+
--- a/utils/s2n_map.h
94+
+++ b/utils/s2n_map.h
95+
@@ -22,7 +22,7 @@
96+
97+
struct s2n_map;
98+
99+
-extern struct s2n_map *s2n_map_new();
100+
+extern struct s2n_map *s2n_map_new(void);
101+
extern int s2n_map_add(struct s2n_map *map, struct s2n_blob *key, struct s2n_blob *value);
102+
extern int s2n_map_put(struct s2n_map *map, struct s2n_blob *key, struct s2n_blob *value);
103+
extern int s2n_map_complete(struct s2n_map *map);
104+
diff --git a/utils/s2n_random.c b/utils/s2n_random.c
105+
index 6066d1564..4a2100ac7 100644
106+
--- a/utils/s2n_random.c
107+
+++ b/utils/s2n_random.c
108+
@@ -313,7 +313,7 @@ int s2n_set_private_drbg_for_test(struct s2n_drbg drbg)
109+
}
110+
111+
112+
-int s2n_cpu_supports_rdrand()
113+
+int s2n_cpu_supports_rdrand(void)
114+
{
115+
#if ((defined(__x86_64__) || defined(__i386__)) && (defined(__clang__) || S2N_GCC_VERSION_AT_LEAST(4,3,0)))
116+
uint32_t eax, ebx, ecx, edx;
117+
diff --git a/utils/s2n_safety.c b/utils/s2n_safety.c
118+
index 7e110b75f..90339d926 100644
119+
--- a/utils/s2n_safety.c
120+
+++ b/utils/s2n_safety.c
121+
@@ -29,7 +29,7 @@
122+
* Returns:
123+
* The process ID of the current process
124+
*/
125+
-pid_t s2n_actual_getpid()
126+
+pid_t s2n_actual_getpid(void)
127+
{
128+
#if defined(__GNUC__) && defined(SYS_getpid)
129+
/* http://yarchive.net/comp/linux/getpid_caching.html */
130+
diff --git a/utils/s2n_safety.h b/utils/s2n_safety.h
131+
index 5768f86f8..5f9fad752 100644
132+
--- a/utils/s2n_safety.h
133+
+++ b/utils/s2n_safety.h
134+
@@ -108,7 +108,7 @@ static inline void* trace_memcpy_check(void *restrict to, const void *restrict f
135+
* Returns:
136+
* The process ID of the current process
137+
*/
138+
-extern pid_t s2n_actual_getpid();
139+
+extern pid_t s2n_actual_getpid(void);
140+
141+
/* Returns 1 if a and b are equal, in constant time */
142+
extern int s2n_constant_time_equals(const uint8_t * a, const uint8_t * b, uint32_t len);

0 commit comments

Comments
 (0)