1
1
package org .bouncycastle .jcajce .provider .asymmetric .mldsa ;
2
2
3
- import java .io .ByteArrayOutputStream ;
4
3
import java .security .InvalidKeyException ;
5
4
import java .security .NoSuchAlgorithmException ;
6
5
import java .security .PrivateKey ;
18
17
public class SignatureSpi
19
18
extends java .security .Signature
20
19
{
21
- private ByteArrayOutputStream bOut ;
22
20
private MLDSASigner signer ;
23
21
private MLDSAParameters parameters ;
24
22
25
23
protected SignatureSpi (MLDSASigner signer )
26
24
{
27
25
super ("MLDSA" );
28
26
29
- this .bOut = new ByteArrayOutputStream ();
30
27
this .signer = signer ;
31
28
this .parameters = null ;
32
29
}
@@ -35,7 +32,6 @@ protected SignatureSpi(MLDSASigner signer, MLDSAParameters parameters)
35
32
{
36
33
super (MLDSAParameterSpec .fromName (parameters .getName ()).getName ());
37
34
38
- this .bOut = new ByteArrayOutputStream ();
39
35
this .signer = signer ;
40
36
this .parameters = parameters ;
41
37
}
@@ -109,26 +105,20 @@ protected void engineInitSign(PrivateKey privateKey)
109
105
protected void engineUpdate (byte b )
110
106
throws SignatureException
111
107
{
112
- bOut . write (b );
108
+ signer . update (b );
113
109
}
114
110
115
111
protected void engineUpdate (byte [] b , int off , int len )
116
112
throws SignatureException
117
113
{
118
- bOut . write (b , off , len );
114
+ signer . update (b , off , len );
119
115
}
120
116
121
117
protected byte [] engineSign ()
122
118
throws SignatureException
123
119
{
124
120
try
125
121
{
126
- byte [] message = bOut .toByteArray ();
127
-
128
- bOut .reset ();
129
-
130
- signer .update (message , 0 , message .length );
131
-
132
122
return signer .generateSignature ();
133
123
}
134
124
catch (Exception e )
@@ -140,12 +130,6 @@ protected byte[] engineSign()
140
130
protected boolean engineVerify (byte [] sigBytes )
141
131
throws SignatureException
142
132
{
143
- byte [] message = bOut .toByteArray ();
144
-
145
- bOut .reset ();
146
-
147
- signer .update (message , 0 , message .length );
148
-
149
133
return signer .verifySignature (sigBytes );
150
134
}
151
135
0 commit comments