Class Crypto_SealedObject
- All Implemented Interfaces:
Serializable
Crypto_SealedPair
in generated code.
Internally the encrypted key, encrypted message and cipher scheme are stored
as raw byte arrays - the natural format for Protocol Buffers. Custom Java
serialisation guarantees that the wire format is identical to
Crypto_SealedPair, making the class compatible with older AnBxJ
versions.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCrypto_SealedObject(byte[] encryptedKey, byte[] encryptedMessage, String cipherScheme) Constructs a newCrypto_SealedObjectfrom raw fields.Constructs a newCrypto_SealedObjectfrom an existingCrypto_SealedPair(JavaSer compatibility). -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic Crypto_SealedObjectReconstructs aCrypto_SealedObjectfrom a ProtobufAnBx_WireFormats.SealedMessage.Returns the cipher scheme string.byte[]Returns a copy of the encrypted key bytes, ornullif no key was transported.byte[]Returns a copy of the encrypted message bytes.inthashCode()byte[]Produces a deterministic byte array that can be parsed byAnBx_WireFormats.SealedMessage.parseFrom(byte[]).Converts aCrypto_SealedObjectto its ProtobufAnBx_WireFormats.SealedMessagerepresentation.Converts this container into a Protobuf-compatibleAnBx_WireFormats.SealedMessage.Reconstructs an old-styleCrypto_SealedPairfrom the raw fields stored in this object.toString()
-
Constructor Details
-
Crypto_SealedObject
Constructs a newCrypto_SealedObjectfrom an existingCrypto_SealedPair(JavaSer compatibility).The sealed key and sealed message inside the pair are serialised to byte arrays so that the object can be stored in a mode-independent way. The original pair is not retained; instead its fields are extracted into the raw byte representation that all serialisers can work with.
- Parameters:
pair- the old-style sealed pair (must not benull)- Throws:
AnBx_LibraryException- if serialisation of the pair's fields fails
-
Crypto_SealedObject
Constructs a newCrypto_SealedObjectfrom raw fields. This constructor is used when the object is created directly from protobuf fields (e.g. inProtoBufNewor the newProtoBufserialiser).- Parameters:
encryptedKey- the encrypted symmetric key (may benullif no key transport is used)encryptedMessage- the encrypted message payloadcipherScheme- the cipher scheme used (e.g."AES/GCM/NoPadding")
-
-
Method Details
-
getEncryptedKey
public byte[] getEncryptedKey()Returns a copy of the encrypted key bytes, ornullif no key was transported.- Returns:
- the encrypted key, or
null
-
getEncryptedMessage
public byte[] getEncryptedMessage()Returns a copy of the encrypted message bytes.- Returns:
- the encrypted message
-
getCipherScheme
Returns the cipher scheme string.- Returns:
- the cipher scheme (never
null)
-
toSealedPair
Reconstructs an old-styleCrypto_SealedPairfrom the raw fields stored in this object. This is used by the runtime when the serialiser isJavaSerand the engine expects aCrypto_SealedPair.- Returns:
- the reconstructed
Crypto_SealedPair - Throws:
AnBx_LibraryException- if deserialisation fails
-
toByteArray
public byte[] toByteArray()Produces a deterministic byte array that can be parsed byAnBx_WireFormats.SealedMessage.parseFrom(byte[]).The binary layout is identical to
AnBx_WireFormats.SealedMessage.toByteArray().- Returns:
- the serialised bytes (never
null)
-
toSealedMessage
Converts this container into a Protobuf-compatibleAnBx_WireFormats.SealedMessage.The returned message holds the same encrypted key, encrypted message and cipher scheme as this object. It can be used directly by the typed Protobuf serialiser.
- Returns:
- a new
SealedMessage(nevernull)
-
toProtobufSealed
Converts aCrypto_SealedObjectto its ProtobufAnBx_WireFormats.SealedMessagerepresentation.- Parameters:
obj- the sealed object to convert- Returns:
- the corresponding
SealedMessage
-
fromProtobufSealed
Reconstructs aCrypto_SealedObjectfrom a ProtobufAnBx_WireFormats.SealedMessage.- Parameters:
msg- the Protobuf message- Returns:
- the reconstructed container
-
hashCode
public int hashCode() -
equals
-
toString
-