From 0c81ffd31a70a320b5038f6f81a24a3b68120241 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 3 Jan 2024 16:34:58 +1100 Subject: [PATCH] tests/multi_net: Generate smaller certs with 2048-bit RSA. Otherwise running the tests can take a long time when the server is a slow target (RP2040 takes 23 seconds for a handshake when using 4096-bit RSA). Also add instructions on how to generate elliptic curve key/certs. Signed-off-by: Damien George --- tests/README.md | 10 ++++++++-- tests/multi_net/rsa_cert.der | Bin 1421 -> 867 bytes tests/multi_net/rsa_key.der | Bin 2347 -> 1217 bytes 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/README.md b/tests/README.md index 083269d6e8..47fcacf409 100644 --- a/tests/README.md +++ b/tests/README.md @@ -181,9 +181,9 @@ SSL/TLS tests in `multi_net` and `net_inet` use a self-signed key/cert pair that is randomly generated and to be used for testing/demonstration only. You should always generate your own key/cert. -To generate a new self-signed key/cert pair with openssl do: +To generate a new self-signed RSA key/cert pair with openssl do: ``` -$ openssl req -x509 -newkey rsa:4096 -keyout rsa_key.pem -out rsa_cert.pem -days 365 -nodes +$ openssl req -x509 -newkey rsa:2048 -keyout rsa_key.pem -out rsa_cert.pem -days 365 -nodes -subj '/CN=micropython.local/O=MicroPython/C=AU' ``` In this case CN is: micropython.local @@ -192,3 +192,9 @@ Convert them to DER format: $ openssl rsa -in rsa_key.pem -out rsa_key.der -outform DER $ openssl x509 -in rsa_cert.pem -out rsa_cert.der -outform DER ``` + +To test elliptic curve key/cert pairs, create a key then a certificate using: +``` +$ openssl ecparam -name prime256v1 -genkey -noout -out ec_key.der -outform DER +$ openssl req -new -x509 -key ec_key.der -out ec_cert.der -outform DER -days 365 -nodes -subj '/CN=micropython.local/O=MicroPython/C=AU' +``` diff --git a/tests/multi_net/rsa_cert.der b/tests/multi_net/rsa_cert.der index 24ed957eb2c5a21ec4e351abce0c802645462b02..8fae71d4baa8cd3e2be3f3d2bedb62ebb33e371c 100644 GIT binary patch literal 867 zcmXqLVvaXxVsc-=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g$!Q4(*xH zGv#5*#D7vsXD99WY$MoWYJF!$Oh=J^>XQbQiTp(drUx!tSIpGV%-=Zq+%Z#*78PrT z{eeze7v^tg)V_J@N?``GllFs)g7?Wr zAkaV-m~v(LSj1RFYAv;zR=atc{jDugN}CdzrRn;&*FYX5t;`}}Al86g0Y6BAFeBrC z7FGjhAcdUlfVm2o>=+r=IUEpu{OVrs>JxsC!`IBs^sBix=gGoNsU1wk7n8yTXD!#? zw5q#BPGjc2#V;}$-9GtFvoddrnY_Ow#QjdzhS~9&?&-3pgf~8ykFj%Rlr1@XtmCba z=w`-*!gWQa*Xt{7tG4V^zIuHo>-Qhq7WOzjN&9z9zh&FgskN^jO!HmcVz%MI zSw9X&wZvV&r*{1QTafWLhhuf6fRy+BN3v7T@;z8}{ce}tMGbZtzC#z1@8teUmY5f~ oKXy{&^Rnwn_9aopUmohkXixC8eR#|{+jyP`L#Ldb>0yCz0E4|}w*UYD diff --git a/tests/multi_net/rsa_key.der b/tests/multi_net/rsa_key.der index 5a4666402a6a5e7b34bded6c3dd5b59bd49e4d18..c2cfb76d207e7afb33394bbcaf5525d7382dc2b6 100644 GIT binary patch literal 1217 zcmV;y1U~yPf&{$+0RS)!1_>&LNQUrr!ay9qXGc{0)hbn0LZlpRD`B= z9t9&SjV$Giv?z(F5>j2*FZYr}H!saOt`e3UbP_IzNWbmzHKD49j+v1dbUwEdbf^j^ zlrWm)&s>>O{1#~830zcx*6GlfNp!&A^&rcKCef|sUuZ>>e$^!hXNN<%`3xC2e~1EQ68WdaUJHGH6KNdf}_009Dm0RSW} zE{uuQ59_yeU6yxmaqG|;@P|zO$;j){93}3e3Ng(4?rA0!=}%+%+OL*V4Op>iEQDAA z+uBBMa|DdLj^L zh2>yytH@+-8JoegV^T#X1+$KCb{_(PfdJW>=*RfG!M;vGYUSVov*B)gB2e0lZJ`Ot z{m-JTH`87cEMkJFkmPGH8{9`dhN8^bciA$-J=V6fn#a~2FJRRUe}rMH$}fUo9PtXs zP@5c3Y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