Package anbxj
Class Crypto_SealedObject
java.lang.Object
anbxj.Crypto_SealedObject
- All Implemented Interfaces:
Serializable
Universal sealed (encrypted) container for both symmetric and hybrid encryption.
Internally the encrypted key, encrypted message and cipher scheme are stored as raw byte arrays - a format suitable for both Java serialisation and Protocol Buffers.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCrypto_SealedObject(byte[] encryptedKey, byte[] encryptedMessage, String cipherScheme) Constructs a newCrypto_SealedObjectfrom raw fields. -
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.toString()
-
Constructor Details
-
Crypto_SealedObject
Constructs a newCrypto_SealedObjectfrom raw fields.- Parameters:
encryptedKey- the encrypted symmetric key (may benullif no key transport is used)encryptedMessage- the encrypted message payload (must not benull)cipherScheme- the cipher scheme used (e.g."AES/GCM/NoPadding")- Throws:
NullPointerException- ifencryptedMessageorcipherSchemeisnull
-
-
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 (never
null)
-
getCipherScheme
Returns the cipher scheme string.- Returns:
- the cipher scheme (never
null)
-
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.- 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
-