@Immutable public final class LegacyProtoKey extends Key
| Constructor and Description |
|---|
LegacyProtoKey(ProtoKeySerialization serialization,
SecretKeyAccess access)
Creates a new LegacyProtoKey object.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equalsKey(Key key)
Returns true if we are sure that the other key is the same.
|
Integer |
getIdRequirementOrNull()
Returns null if this key has no id requirement, otherwise the required id.
|
Parameters |
getParameters()
Returns a LegacyParametersNotForCreation object.
|
ProtoKeySerialization |
getSerialization(SecretKeyAccess access)
Returns the protokeyserialization with which this object was created.
|
public LegacyProtoKey(ProtoKeySerialization serialization, @Nullable SecretKeyAccess access) throws GeneralSecurityException
Access is required for SYMMETRIC and ASYMMETRIC_PRIVATE key material types.
GeneralSecurityExceptionpublic boolean equalsKey(Key key)
Due to the fact that proto key serialization isn't guaranteed to be deterministic, this isn't guaranteed to be true in case two serializations are actually the same. This shouldn't be a problem: the use of key equality is that one can implement keyset equality, which is useful when one wants the guarantee that two keysets are the same (for example, when one changes the source of the keyset from disk to a remotely stored keyset). Since the only thing which can happen is that we falsely return "false", this can then be solved in debugging. (The alternative would be to throw an UnsupportedOperationException while we add the real implementations of keys)
@Nullable public Integer getIdRequirementOrNull()
KeySome keys, when they are in a keyset, are required to have a certain ID to work properly.
This comes from the fact that Tink in some cases prefixes ciphertexts or signatures with the
string 0x01<id>, where the ID is encoded in big endian (see the documentation of the
key type for details), in which case the key requires a certain ID.
getIdRequirementOrNull in class Keypublic ProtoKeySerialization getSerialization(@Nullable SecretKeyAccess access) throws GeneralSecurityException
Access is required for SYMMETRIC and ASYMMETRIC_PRIVATE key material types.
GeneralSecurityExceptionpublic Parameters getParameters()
Note: this is different from the LegacyProtoParameters object which was used to
create this key. One cannot use the returned object to create a new key.
getParameters in class Key