File tree 4 files changed +25
-14
lines changed
4 files changed +25
-14
lines changed Original file line number Diff line number Diff line change 19
19
test_vector = Vector {UInt8} ([1 ,2 ,3 ])
20
20
Random. seed! (42 )
21
21
padded = ToyPublicKeys. pad (ToyPublicKeys. pkcs1_v1_5, test_vector)
22
- @test ToyPublicKeys. unpad (ToyPublicKeys. pkcs1_v1_5, padded) == test_vector
22
+ unpadded = ToyPublicKeys. unpad (ToyPublicKeys. pkcs1_v1_5, padded)
23
+ @test unpadded == test_vector
23
24
end
24
25
25
26
@testset " padding/pkcs_1_v2_2 pad(unpad) is identity" begin
26
- test_vector = Vector {UInt8} ([1 ,2 ,3 ])
27
+ test_vector = Vector {UInt8} ([3 ,2 ,1 ])
27
28
Random. seed! (42 )
28
29
private_key, public_key = ToyPublicKeys. generate_rsa_key_pair (ToyPublicKeys. pkcs1_v1_5, 2048 )
29
30
padded = ToyPublicKeys. pad (ToyPublicKeys. pkcs1_v2_2,
30
31
test_vector,
31
32
public_key)
32
- @test test_vector == ToyPublicKeys. unpad (ToyPublicKeys. pkcs1_v2_2,
33
- padded,
34
- public_key)
33
+ unpadded = ToyPublicKeys. unpad (ToyPublicKeys. pkcs1_v2_2,
34
+ padded,
35
+ public_key)
36
+ @test unpadded == test_vector
35
37
end
Original file line number Diff line number Diff line change 117
117
signature = ToyPublicKeys. RSASP1 (ToyPublicKeys. pkcs1_v1_5, msg, private_key)
118
118
@test ToyPublicKeys. RSAVP1 (ToyPublicKeys. pkcs1_v1_5, signature, public_key) == msg
119
119
end
120
+
121
+ @testset " rsaes_oaep_decrypt(rsaes_oaep_encrypt) is true" begin
122
+ Random. seed! (42 )
123
+ private_key, public_key = ToyPublicKeys. generate_rsa_key_pair (ToyPublicKeys. pkcs1_v1_5, 2048 )
124
+ msg = Vector {UInt8} (" 123" )
125
+ C = ToyPublicKeys. rsaes_oaep_encrypt (msg, public_key)
126
+ ret = ToyPublicKeys. rsaes_oaep_decrypt (C, private_key)
127
+ @test ret == msg
128
+ end
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ using ToyPublicKeys
2
2
using Test
3
3
import Random
4
4
5
+ include (" utils.jl" )
6
+ include (" padding.jl" )
5
7
include (" rsa.jl" )
6
8
include (" dh.jl" )
7
- include (" padding.jl" )
8
- include (" utils.jl" )
Original file line number Diff line number Diff line change 1
- @testset " I2OSP " begin
1
+ @testset " i2osp " begin
2
2
b = big " 255"
3
- @test b |> ToyPublicKeys. I2OSP == " FF"
4
- @test b |> x -> ToyPublicKeys. I2OSP (x, 3 ) == " 00:FF"
3
+ @test b |> ToyPublicKeys. i2osp == " FF"
4
+ @test b |> x -> ToyPublicKeys. i2osp (x, 3 ) == " 00:FF"
5
5
end
6
6
7
- @testset " OS2IP " begin
7
+ @testset " os2ip " begin
8
8
b = " FF"
9
- @test b |> ToyPublicKeys. OS2IP == big " 255"
9
+ @test b |> ToyPublicKeys. os2ip == big " 255"
10
10
end
11
11
12
- @testset " I2OSP |> OS2IP " begin
12
+ @testset " i2osp |> os2ip " begin
13
13
b = big " 255"
14
- @test b |> ToyPublicKeys. I2OSP |> ToyPublicKeys. OS2IP == b
14
+ @test b |> ToyPublicKeys. i2osp |> ToyPublicKeys. os2ip == b
15
15
end
You can’t perform that action at this time.
0 commit comments