Skip to content

Commit 402aed6

Browse files
committed
Merge branch 'main' of gitlab.cryptoworkshop.com:root/bc-java
2 parents 400d275 + 4b68479 commit 402aed6

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
11
/**
22
* Classes for parameter objects for ciphers and generators.
3+
* <p>
4+
* Several parameter types in this package are <b>wrappers</b>: each carries one extra value and a
5+
* {@code getParameters()} link to the {@link org.bouncycastle.crypto.CipherParameters} it decorates,
6+
* so a caller supplies a nested chain ending in a key. The wrappers are
7+
* {@link org.bouncycastle.crypto.params.ParametersWithContext},
8+
* {@link org.bouncycastle.crypto.params.ParametersWithID},
9+
* {@link org.bouncycastle.crypto.params.ParametersWithRandom},
10+
* {@link org.bouncycastle.crypto.params.ParametersWithUKM},
11+
* {@link org.bouncycastle.crypto.params.ParametersWithIV},
12+
* {@link org.bouncycastle.crypto.params.ParametersWithSBox} and
13+
* {@link org.bouncycastle.crypto.params.ParametersWithSalt}.
14+
* <p>
15+
* There is no enforced nesting order, but the implementations share a de facto one. A component
16+
* unwraps only the wrapper it consumes and passes the remainder down, so a wrapper sits
17+
* <em>outside</em> everything consumed further down the stack. Outermost first, the order used
18+
* throughout the lightweight API and by the JCE provider when it builds these chains is:
19+
* <ul>
20+
* <li>{@code ParametersWithContext} or {@code ParametersWithID} - a signature context string
21+
* (ML-DSA, SLH-DSA and similar) or a signer identity (SM2, SM9), consumed by the signer.</li>
22+
* <li>{@code ParametersWithRandom} - consumed by the outermost component that needs randomness:
23+
* a signer, an asymmetric encoding, a wrap engine, or a padded buffered cipher. Block cipher
24+
* modes and stream ciphers do not unwrap it, so it must not be nested inside an IV.</li>
25+
* <li>{@code ParametersWithUKM} - the user keying material of the GOST 28147 wrap engines.</li>
26+
* <li>{@code ParametersWithIV} - the IV or nonce, consumed by the cipher mode, stream cipher or
27+
* MAC.</li>
28+
* <li>{@code ParametersWithSBox} - the GOST 28147 S-box, consumed by the engine and so placed
29+
* directly around the key.</li>
30+
* <li>the key itself: {@link org.bouncycastle.crypto.params.KeyParameter} or an
31+
* {@link org.bouncycastle.crypto.params.AsymmetricKeyParameter}.</li>
32+
* </ul>
33+
* So, for example, a GOST 28147 CBC cipher takes {@code IV(SBox(key))}, a padded CBC cipher takes
34+
* {@code Random(IV(key))}, and an ML-DSA signer takes {@code Context(Random(privateKey))}.
35+
* <p>
36+
* {@code ParametersWithSalt} is used only by
37+
* {@link org.bouncycastle.crypto.signers.ISO9796d2PSSSigner}, which accepts it as an alternative
38+
* to {@code ParametersWithRandom} rather than nested with it. A few GOST classes
39+
* ({@link org.bouncycastle.crypto.macs.GOST28147Mac} in particular) accept their wrappers in any
40+
* order; most implementations do not, and a chain nested against the order above is usually
41+
* rejected with an {@code IllegalArgumentException} or a {@code ClassCastException}.
42+
* {@link org.bouncycastle.crypto.params.AEADParameters} is a self-contained alternative to
43+
* {@code ParametersWithIV} for AEAD modes and combines key, nonce, tag length and associated data
44+
* without nesting.
345
*/
446
package org.bouncycastle.crypto.params;

0 commit comments

Comments
 (0)