@@ -49,7 +49,7 @@ public void Create_ReturnsPivPublicKey(
49
49
{
50
50
ReadOnlyMemory < byte > keyData = GetKeyData ( keyType ) ;
51
51
52
- var keyObject = PivPublicKey . Create ( keyData ) ;
52
+ var keyObject = PivPublicKey . Create ( keyData , keyType . GetPivAlgorithm ( ) ) ;
53
53
54
54
Assert . True ( keyObject is PivPublicKey ) ;
55
55
}
@@ -64,7 +64,7 @@ public void Create_SetsAlgorithmCorrectly(
64
64
{
65
65
ReadOnlyMemory < byte > keyData = GetKeyData ( keyType ) ;
66
66
67
- var keyObject = PivPublicKey . Create ( keyData ) ;
67
+ var keyObject = PivPublicKey . Create ( keyData , keyType . GetPivAlgorithm ( ) ) ;
68
68
69
69
Assert . NotNull ( keyObject ) ;
70
70
Assert . Equal ( keyType . GetPivAlgorithm ( ) , keyObject . Algorithm ) ;
@@ -81,7 +81,7 @@ public void Create_SetsEncodedCorrectly(
81
81
ReadOnlyMemory < byte > keyData = GetKeyData ( keyType ) ;
82
82
ReadOnlyMemory < byte > encoding = GetCorrectEncoding ( keyType ) ;
83
83
84
- var keyObject = PivPublicKey . Create ( keyData ) ;
84
+ var keyObject = PivPublicKey . Create ( keyData , keyType . GetPivAlgorithm ( ) ) ;
85
85
Assert . NotNull ( keyObject ) ;
86
86
87
87
ReadOnlyMemory < byte > getKeyData = keyObject . PivEncodedPublicKey ;
@@ -101,7 +101,7 @@ public void Create_SetsMetadataEncodedCorrectly(
101
101
ReadOnlyMemory < byte > keyData = GetKeyData ( keyType ) ;
102
102
ReadOnlyMemory < byte > encoding = GetCorrectMetadataEncoding ( keyType ) ;
103
103
104
- var keyObject = PivPublicKey . Create ( keyData ) ;
104
+ var keyObject = PivPublicKey . Create ( keyData , keyType . GetPivAlgorithm ( ) ) ;
105
105
Assert . NotNull ( keyObject ) ;
106
106
107
107
ReadOnlyMemory < byte > getKeyData = keyObject . YubiKeyEncodedPublicKey ;
@@ -120,7 +120,7 @@ public void CreateRsa_SetsModulusCorrectly(
120
120
ReadOnlyMemory < byte > keyData = GetKeyData ( keyType ) ;
121
121
ReadOnlyMemory < byte > modulus = GetModulus ( keyType ) ;
122
122
123
- var keyObject = PivPublicKey . Create ( keyData ) ;
123
+ var keyObject = PivPublicKey . Create ( keyData , keyType . GetPivAlgorithm ( ) ) ;
124
124
125
125
Assert . NotNull ( keyObject ) ;
126
126
Assert . True ( keyObject is PivRsaPublicKey ) ;
@@ -145,7 +145,7 @@ public void CreateRsa_SetsExponentCorrectly(
145
145
ReadOnlyMemory < byte > keyData = SampleKeyPairs . GetPivPublicKey ( keyType ) . PivEncodedPublicKey ;
146
146
ReadOnlyMemory < byte > exponent = GetExponent ( ) ;
147
147
148
- var keyObject = PivPublicKey . Create ( keyData ) ;
148
+ var keyObject = PivPublicKey . Create ( keyData , keyType . GetPivAlgorithm ( ) ) ;
149
149
150
150
Assert . NotNull ( keyObject ) ;
151
151
Assert . True ( keyObject is PivRsaPublicKey ) ;
@@ -168,7 +168,7 @@ public void CreateEcc_SetsPublicPointCorrectly(
168
168
ReadOnlyMemory < byte > keyData = GetKeyData ( keyType ) ;
169
169
ReadOnlyMemory < byte > publicPoint = GetPoint ( keyType ) ;
170
170
171
- var keyObject = PivPublicKey . Create ( keyData ) ;
171
+ var keyObject = PivPublicKey . Create ( keyData , keyType . GetPivAlgorithm ( ) ) ;
172
172
173
173
Assert . NotNull ( keyObject ) ;
174
174
Assert . True ( keyObject is PivEccPublicKey ) ;
@@ -224,23 +224,23 @@ public void EccConstructor_Components_BuildsEncoding(
224
224
[ Fact ]
225
225
public void Create_NullData_ThrowsException ( )
226
226
{
227
- _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( null ) ) ;
227
+ _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( null , PivAlgorithm . EccP256 ) ) ;
228
228
}
229
229
230
230
[ Fact ]
231
231
public void Create_BadTag_ThrowsExcpetion ( )
232
232
{
233
233
Memory < byte > keyData = GetKeyData ( KeyType . P256 ) ;
234
234
keyData . Span [ 0 ] = 0x84 ;
235
- _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( keyData ) ) ;
235
+ _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( keyData , KeyType . P256 . GetPivAlgorithm ( ) ) ) ;
236
236
}
237
237
238
238
[ Fact ]
239
239
public void Rsa_NoExpo_ThrowsExcpetion ( )
240
240
{
241
241
Memory < byte > keyData = GetKeyData ( KeyType . RSA1024 ) ;
242
242
Memory < byte > badData = keyData . Slice ( keyData . Length - 6 ) ;
243
- _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( badData ) ) ;
243
+ _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( badData , PivAlgorithm . Rsa1024 ) ) ;
244
244
}
245
245
246
246
[ Theory ]
@@ -250,7 +250,7 @@ public void RsaConstructor_BadMod_ThrowsExcpetion(
250
250
KeyType keyType )
251
251
{
252
252
Memory < byte > keyData = GetBadEncoding ( keyType ) ;
253
- _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( keyData ) ) ;
253
+ _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( keyData , keyType . GetPivAlgorithm ( ) ) ) ;
254
254
}
255
255
256
256
[ Fact ]
@@ -275,7 +275,7 @@ public void EccConstructor_BadPoint_ThrowsExcpetion(
275
275
KeyType keyType )
276
276
{
277
277
Memory < byte > keyData = GetBadEncoding ( keyType ) ;
278
- _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( keyData ) ) ;
278
+ _ = Assert . Throws < ArgumentException > ( ( ) => PivPublicKey . Create ( keyData , keyType . GetPivAlgorithm ( ) ) ) ;
279
279
}
280
280
281
281
private static Memory < byte > GetModulus (
0 commit comments