Skip to content

Commit 5c53dfa

Browse files
crypto-test: generate and encrypt RC4 test messages
With openssl. N.B., only the "-K" option to "openssl enc" allows specifying a raw RC4 key (in hex), all others (-k, -kfile, -pass) go through a KDF (sha256, by default) which is not what the mobilpay flow does.
1 parent b496bfd commit 5c53dfa

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docker/crypto-test/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@ RUN \
1919
-out $d/public.pem \
2020
-subj "/OU=test/CN=$side" \
2121
-days 36525 ; \
22+
openssl rsa \
23+
-in $d/private.pem \
24+
-out $d/rawpublic.pem \
25+
-outform PEM \
26+
-pubout ; \
27+
echo "message from $side" > $d/msg.clear ; \
28+
openssl rand 16 > $d/enc.key ; \
29+
openssl enc \
30+
-rc4 \
31+
-nosalt \
32+
-in $d/msg.clear \
33+
-out $d/msg.enc \
34+
-K $(od -tx1 -An < $d/enc.key | tr -d ' ') ; \
35+
base64 -w0 < $d/msg.enc > $d/msg.enc.b64 ; \
36+
openssl rsautl \
37+
-encrypt \
38+
-inkey $d/rawpublic.pem \
39+
-pubin \
40+
-in $d/enc.key \
41+
-out $d/enc.key.rsaenc ; \
42+
base64 -w0 < $d/enc.key.rsaenc > $d/enc.key.rsaenc.b64 ; \
2243
done ; \
2344
done
2445

0 commit comments

Comments
 (0)