8285389: EdDSA trimming zeros

Reviewed-by: xuelei
This commit is contained in:
Anthony Scarpino 2022-04-25 15:31:49 +00:00
parent 293bc5e5cd
commit 414918d911

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -134,6 +134,11 @@ public class EdDSAOperations {
if (signature == null) { if (signature == null) {
throw new SignatureException("signature was null"); throw new SignatureException("signature was null");
} }
if (params.getKeyLength() * 2 != signature.length) {
throw new SignatureException("signature length invalid");
}
byte[] encR = Arrays.copyOf(signature, signature.length / 2); byte[] encR = Arrays.copyOf(signature, signature.length / 2);
byte[] encS = Arrays.copyOfRange(signature, signature.length / 2, byte[] encS = Arrays.copyOfRange(signature, signature.length / 2,
signature.length); signature.length);