@@ -21,11 +21,11 @@ use std::{convert::TryFrom, ops::Add, sync::Mutex};
21
21
use digest:: { Digest , FixedOutput , Output } ;
22
22
use ecdsa:: {
23
23
der:: { MaxOverhead , MaxSize , Signature as DerSignature } ,
24
- hazmat:: { DigestPrimitive , SignPrimitive } ,
25
- Signature , SignatureSize , VerifyingKey ,
24
+ hazmat:: DigestPrimitive ,
25
+ EcdsaCurve , Signature , SignatureSize , VerifyingKey ,
26
26
} ;
27
27
use elliptic_curve:: {
28
- generic_array :: ArrayLength ,
28
+ array :: ArraySize ,
29
29
ops:: Invert ,
30
30
sec1:: { FromEncodedPoint , ModulusSize , ToEncodedPoint } ,
31
31
subtle:: CtOption ,
@@ -70,7 +70,7 @@ use x509_cert::{
70
70
#[ derive( Debug ) ]
71
71
pub struct EcSigner < ' ctx , C >
72
72
where
73
- C : PrimeCurve + CurveArithmetic ,
73
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve ,
74
74
{
75
75
context : Mutex < & ' ctx mut TransientKeyContext > ,
76
76
key_material : KeyMaterial ,
80
80
81
81
impl < ' ctx , C > EcSigner < ' ctx , C >
82
82
where
83
- C : PrimeCurve + CurveArithmetic ,
83
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve ,
84
84
C : AssociatedTpmCurve ,
85
85
FieldBytesSize < C > : ModulusSize ,
86
86
AffinePoint < C > : FromEncodedPoint < C > + ToEncodedPoint < C > ,
@@ -106,7 +106,7 @@ where
106
106
107
107
impl < C > EcSigner < ' _ , C >
108
108
where
109
- C : PrimeCurve + CurveArithmetic ,
109
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve ,
110
110
C : AssociatedTpmCurve ,
111
111
{
112
112
/// Key parameters for this curve, selected digest is the one selected by DigestPrimitive
@@ -126,7 +126,7 @@ where
126
126
/// The hashing algorithm `D` is the digest that will be used for signatures (SHA-256, SHA3-256, ...).
127
127
pub fn key_params < D > ( ) -> KeyParams
128
128
where
129
- D : FixedOutput < OutputSize = FieldBytesSize < C > > ,
129
+ D : FixedOutput ,
130
130
D : AssociatedHashingAlgorithm ,
131
131
{
132
132
KeyParams :: Ecc {
@@ -139,9 +139,9 @@ where
139
139
140
140
impl < C > AsRef < VerifyingKey < C > > for EcSigner < ' _ , C >
141
141
where
142
- C : PrimeCurve + CurveArithmetic ,
143
- Scalar < C > : Invert < Output = CtOption < Scalar < C > > > + SignPrimitive < C > ,
144
- SignatureSize < C > : ArrayLength < u8 > ,
142
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve ,
143
+ Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
144
+ SignatureSize < C > : ArraySize ,
145
145
{
146
146
fn as_ref ( & self ) -> & VerifyingKey < C > {
147
147
& self . verifying_key
@@ -150,21 +150,21 @@ where
150
150
151
151
impl < C > KeypairRef for EcSigner < ' _ , C >
152
152
where
153
- C : PrimeCurve + CurveArithmetic ,
154
- Scalar < C > : Invert < Output = CtOption < Scalar < C > > > + SignPrimitive < C > ,
155
- SignatureSize < C > : ArrayLength < u8 > ,
153
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve ,
154
+ Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
155
+ SignatureSize < C > : ArraySize ,
156
156
{
157
157
type VerifyingKey = VerifyingKey < C > ;
158
158
}
159
159
160
160
impl < C , D > DigestSigner < D , Signature < C > > for EcSigner < ' _ , C >
161
161
where
162
- C : PrimeCurve + CurveArithmetic ,
162
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve ,
163
163
C : AssociatedTpmCurve ,
164
- D : Digest + FixedOutput < OutputSize = FieldBytesSize < C > > ,
164
+ D : Digest + FixedOutput ,
165
165
D : AssociatedHashingAlgorithm ,
166
- Scalar < C > : Invert < Output = CtOption < Scalar < C > > > + SignPrimitive < C > ,
167
- SignatureSize < C > : ArrayLength < u8 > ,
166
+ Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
167
+ SignatureSize < C > : ArraySize ,
168
168
TpmDigest : From < Output < D > > ,
169
169
{
170
170
fn try_sign_digest ( & self , digest : D ) -> Result < Signature < C > , SigError > {
@@ -195,16 +195,16 @@ where
195
195
196
196
impl < C , D > DigestSigner < D , DerSignature < C > > for EcSigner < ' _ , C >
197
197
where
198
- C : PrimeCurve + CurveArithmetic ,
198
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve ,
199
199
C : AssociatedTpmCurve ,
200
- D : Digest + FixedOutput < OutputSize = FieldBytesSize < C > > ,
200
+ D : Digest + FixedOutput ,
201
201
D : AssociatedHashingAlgorithm ,
202
- Scalar < C > : Invert < Output = CtOption < Scalar < C > > > + SignPrimitive < C > ,
203
- SignatureSize < C > : ArrayLength < u8 > ,
202
+ Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
203
+ SignatureSize < C > : ArraySize ,
204
204
TpmDigest : From < Output < D > > ,
205
205
206
- MaxSize < C > : ArrayLength < u8 > ,
207
- <FieldBytesSize < C > as Add >:: Output : Add < MaxOverhead > + ArrayLength < u8 > ,
206
+ MaxSize < C > : ArraySize ,
207
+ <FieldBytesSize < C > as Add >:: Output : Add < MaxOverhead > + ArraySize ,
208
208
{
209
209
fn try_sign_digest ( & self , digest : D ) -> Result < DerSignature < C > , SigError > {
210
210
let signature: Signature < _ > = self . try_sign_digest ( digest) ?;
@@ -214,11 +214,11 @@ where
214
214
215
215
impl < C > Signer < Signature < C > > for EcSigner < ' _ , C >
216
216
where
217
- C : PrimeCurve + CurveArithmetic + DigestPrimitive ,
217
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve + DigestPrimitive ,
218
218
C : AssociatedTpmCurve ,
219
219
<C as DigestPrimitive >:: Digest : AssociatedHashingAlgorithm ,
220
- Scalar < C > : Invert < Output = CtOption < Scalar < C > > > + SignPrimitive < C > ,
221
- SignatureSize < C > : ArrayLength < u8 > ,
220
+ Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
221
+ SignatureSize < C > : ArraySize ,
222
222
TpmDigest : From < Output < <C as DigestPrimitive >:: Digest > > ,
223
223
{
224
224
fn try_sign ( & self , msg : & [ u8 ] ) -> Result < Signature < C > , SigError > {
@@ -228,15 +228,15 @@ where
228
228
229
229
impl < C > Signer < DerSignature < C > > for EcSigner < ' _ , C >
230
230
where
231
- C : PrimeCurve + CurveArithmetic + DigestPrimitive ,
231
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve + DigestPrimitive ,
232
232
C : AssociatedTpmCurve ,
233
233
<C as DigestPrimitive >:: Digest : AssociatedHashingAlgorithm ,
234
- Scalar < C > : Invert < Output = CtOption < Scalar < C > > > + SignPrimitive < C > ,
235
- SignatureSize < C > : ArrayLength < u8 > ,
234
+ Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
235
+ SignatureSize < C > : ArraySize ,
236
236
TpmDigest : From < Output < <C as DigestPrimitive >:: Digest > > ,
237
237
238
- MaxSize < C > : ArrayLength < u8 > ,
239
- <FieldBytesSize < C > as Add >:: Output : Add < MaxOverhead > + ArrayLength < u8 > ,
238
+ MaxSize < C > : ArraySize ,
239
+ <FieldBytesSize < C > as Add >:: Output : Add < MaxOverhead > + ArraySize ,
240
240
{
241
241
fn try_sign ( & self , msg : & [ u8 ] ) -> Result < DerSignature < C > , SigError > {
242
242
self . try_sign_digest ( C :: Digest :: new_with_prefix ( msg) )
@@ -245,9 +245,9 @@ where
245
245
246
246
impl < C > SignatureAlgorithmIdentifier for EcSigner < ' _ , C >
247
247
where
248
- C : PrimeCurve + CurveArithmetic ,
249
- Scalar < C > : Invert < Output = CtOption < Scalar < C > > > + SignPrimitive < C > ,
250
- SignatureSize < C > : ArrayLength < u8 > ,
248
+ C : PrimeCurve + CurveArithmetic + EcdsaCurve ,
249
+ Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
250
+ SignatureSize < C > : ArraySize ,
251
251
Signature < C > : AssociatedAlgorithmIdentifier < Params = AnyRef < ' static > > ,
252
252
{
253
253
type Params = AnyRef < ' static > ;
0 commit comments