@@ -178,16 +178,20 @@ public PGPSignature generate()
178
178
sigValues = new MPInteger [1 ];
179
179
sigValues [0 ] = new MPInteger (new BigInteger (1 , contentSigner .getSignature ()));
180
180
}
181
- else if (contentSigner .getKeyAlgorithm () == PublicKeyAlgorithmTags .EDDSA_LEGACY ||
182
- contentSigner .getKeyAlgorithm () == PublicKeyAlgorithmTags .Ed25519 ||
183
- contentSigner .getKeyAlgorithm () == PublicKeyAlgorithmTags .Ed448 )
181
+ else if (contentSigner .getKeyAlgorithm () == PublicKeyAlgorithmTags .EDDSA_LEGACY )
184
182
{
185
183
byte [] enc = contentSigner .getSignature ();
186
184
sigValues = new MPInteger []{
187
185
new MPInteger (new BigInteger (1 , Arrays .copyOfRange (enc , 0 , enc .length / 2 ))),
188
186
new MPInteger (new BigInteger (1 , Arrays .copyOfRange (enc , enc .length / 2 , enc .length )))
189
187
};
190
188
}
189
+ else if (contentSigner .getKeyAlgorithm () == PublicKeyAlgorithmTags .Ed25519 ||
190
+ contentSigner .getKeyAlgorithm () == PublicKeyAlgorithmTags .Ed448 )
191
+ {
192
+ // Contrary to EDDSA_LEGACY, the new PK algorithms Ed25519, Ed448 do not use MPI encoding
193
+ sigValues = null ;
194
+ }
191
195
else
192
196
{
193
197
sigValues = PGPUtil .dsaSigToMpi (contentSigner .getSignature ());
@@ -199,7 +203,14 @@ else if (contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.EDDSA_LEGACY
199
203
fingerPrint [0 ] = digest [0 ];
200
204
fingerPrint [1 ] = digest [1 ];
201
205
202
- return new PGPSignature (new SignaturePacket (sigType , contentSigner .getKeyID (), contentSigner .getKeyAlgorithm (), contentSigner .getHashAlgorithm (), hPkts , unhPkts , fingerPrint , sigValues ));
206
+ if (sigValues != null ) {
207
+ return new PGPSignature (new SignaturePacket (sigType , contentSigner .getKeyID (), contentSigner .getKeyAlgorithm (),
208
+ contentSigner .getHashAlgorithm (), hPkts , unhPkts , fingerPrint , sigValues ));
209
+ } else {
210
+ // Ed25519, Ed448 use raw encoding instead of MPI
211
+ return new PGPSignature (new SignaturePacket (4 , sigType , contentSigner .getKeyID (), contentSigner .getKeyAlgorithm (),
212
+ contentSigner .getHashAlgorithm (), hPkts , unhPkts , fingerPrint , contentSigner .getSignature ()));
213
+ }
203
214
}
204
215
205
216
/**
0 commit comments