public class BuildResponseRecord extends Object
Bytes 0-31 contain the hash of bytes 32-527 Bytes 32-526 contain random data. Byte 527 contains the reply.
| Modifier and Type | Method and Description |
|---|---|
static EncryptedBuildRecord |
create(I2PAppContext ctx,
int status,
SessionKey replyKey,
byte[] replyIV,
long responseMessageId)
Creates a new AES-encrypted response record.
|
static EncryptedBuildRecord |
create(I2PAppContext ctx,
int status,
SessionKey replyKey,
byte[] replyAD,
Properties options)
Creates a new ChaCha/Poly-encrypted response record (long format).
|
static ShortEncryptedBuildRecord |
createShort(I2PAppContext ctx,
int status,
SessionKey replyKey,
byte[] replyAD,
Properties options,
int slot)
Creates a new ChaCha/Poly-encrypted response record (short format).
|
static boolean |
decrypt(EncryptedBuildRecord rec,
SessionKey key,
byte[] ad)
Decrypts a standard ChaCha/Poly-encrypted record.
|
static boolean |
decrypt(EncryptedBuildRecord rec,
SessionKey key,
byte[] ad,
int nonce)
Decrypts a short ChaCha/Poly-encrypted record.
|
public static EncryptedBuildRecord create(I2PAppContext ctx, int status, SessionKey replyKey, byte[] replyIV, long responseMessageId)
ctx - the application contextstatus - the response 0-255replyKey - the session key for reply encryptionreplyIV - 16 bytes IVresponseMessageId - unused except for debuggingpublic static EncryptedBuildRecord create(I2PAppContext ctx, int status, SessionKey replyKey, byte[] replyAD, Properties options)
ctx - the application contextstatus - the response 0-255replyKey - the session key for reply encryptionreplyAD - 32 bytes associated dataoptions - 511 bytes max when serializedIllegalArgumentException - if options too big or on encryption failurepublic static ShortEncryptedBuildRecord createShort(I2PAppContext ctx, int status, SessionKey replyKey, byte[] replyAD, Properties options, int slot)
ctx - the application contextstatus - the response 0-255replyKey - the session key for reply encryptionreplyAD - 32 bytes associated dataoptions - 116 bytes max when serializedslot - the slot number, 0-7IllegalArgumentException - if options too big or on encryption failurepublic static boolean decrypt(EncryptedBuildRecord rec, SessionKey key, byte[] ad)
rec - 528 bytes, data will be decrypted in placekey - the session key for decryptionad - non-null associated data (32 bytes)IllegalArgumentException - if record length is incorrectpublic static boolean decrypt(EncryptedBuildRecord rec, SessionKey key, byte[] ad, int nonce)
rec - 218 bytes, data will be decrypted in placekey - the session key for decryptionad - non-null associated data (32 bytes)nonce - the slot number, 0-7IllegalArgumentException - if record length or nonce is invalid