1
1
Clear-Host
2
- Import-Module - Name Pester - Force
3
2
Import-Module .\Crypto.AES\Crypto.AES.psm1 - Force
4
3
5
4
Describe ' Crypto.AES.Tests' {
@@ -24,9 +23,11 @@ Describe 'Crypto.AES.Tests' {
24
23
}
25
24
26
25
Context " Protect-Data - Result" {
27
- $Key = [byte []]::new(32 )
28
- $nonce = [byte []]::new(12 )
29
- $data = $encoding.GetBytes (" Test" )
26
+ BeforeAll {
27
+ $Key = [byte []]::new(32 )
28
+ $nonce = [byte []]::new(12 )
29
+ $data = $encoding.GetBytes (" Test" )
30
+ }
30
31
31
32
It " has correct size" {
32
33
$r_key = Protect-Data - Key $Key - Data $data - Nonce $nonce
@@ -58,14 +59,16 @@ Describe 'Crypto.AES.Tests' {
58
59
}
59
60
60
61
Context " Protect-Data - signature" {
62
+ BeforeAll {
61
63
$Key = [byte []]::new(32 )
62
- $nonce = [byte []]::new(12 )
64
+ $nonce = [byte []]::new(12 )
63
65
$nonce [0 ] = 104 # random value to test with mock
64
- $data = $encoding.GetBytes (" Test" )
66
+ $data = $encoding.GetBytes (" Test" )
65
67
66
68
Mock - CommandName Get-RandomNonce - ModuleName Crypto.AES - MockWith {
67
69
Write-Output $nonce - NoEnumerate
68
70
}
71
+ }
69
72
70
73
It " optional nonce" {
71
74
$r_explicit = Protect-Data - Key $Key - Data $data - Nonce $nonce
@@ -89,9 +92,11 @@ Describe 'Crypto.AES.Tests' {
89
92
}
90
93
91
94
Context " Protect-Data - nonce" {
92
- $Key = [byte []]::new(32 )
93
- $nonce = [byte []]::new(12 )
94
- $data = $encoding.GetBytes (" Test" )
95
+ BeforeAll {
96
+ $Key = [byte []]::new(32 )
97
+ $nonce = [byte []]::new(12 )
98
+ $data = $encoding.GetBytes (" Test" )
99
+ }
95
100
96
101
It " the same nonce" {
97
102
$a = Protect-Data - Key $Key - Data $data - Nonce $nonce
@@ -115,10 +120,12 @@ Describe 'Crypto.AES.Tests' {
115
120
}
116
121
117
122
Context " Unprotect-Data" {
118
- $Key = [byte []]::new(32 )
119
- [byte []]$nonce = @ (228 , 132 , 78 , 5 , 31 , 60 , 78 , 70 , 192 , 119 , 50 , 184 )
120
- [byte []]$tag = @ (188 , 136 , 244 , 158 , 253 , 2 , 183 , 117 , 127 , 2 , 193 , 66 , 39 , 37 , 94 , 188 )
121
- $data = @ (48 , 22 , 117 , 218 )
123
+ BeforeAll {
124
+ $Key = [byte []]::new(32 )
125
+ [byte []]$nonce = @ (228 , 132 , 78 , 5 , 31 , 60 , 78 , 70 , 192 , 119 , 50 , 184 )
126
+ [byte []]$tag = @ (188 , 136 , 244 , 158 , 253 , 2 , 183 , 117 , 127 , 2 , 193 , 66 , 39 , 37 , 94 , 188 )
127
+ $data = @ (48 , 22 , 117 , 218 )
128
+ }
122
129
123
130
It " has correct size" {
124
131
$r_key = Unprotect-Data - Key $Key - Data $data - Nonce $nonce - Tag $tag
0 commit comments