8347289: HKDF delayed provider selection failed with non-extractable PRK

Reviewed-by: valeriep
This commit is contained in:
Weijun Wang 2025-01-09 01:21:00 +00:00
parent 0a5ef827b0
commit db7fa6a2c6
2 changed files with 108 additions and 4 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -180,8 +180,8 @@ abstract class HKDFKeyDerivation extends KDFSpi {
} else if (derivationSpec instanceof HKDFParameterSpec.Expand anExpand) {
// set this value in the "if"
if ((pseudoRandomKey = anExpand.prk().getEncoded()) == null) {
throw new AssertionError(
"PRK is required for HKDFParameterSpec.Expand");
throw new InvalidAlgorithmParameterException(
"Cannot retrieve PRK for HKDFParameterSpec.Expand");
}
// set this value in the "if"
if ((info = anExpand.info()) == null) {
@ -411,4 +411,4 @@ abstract class HKDFKeyDerivation extends KDFSpi {
}
}
}
}