Debian Codegraph @

src/main/org/h2/security/BlockCipher.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.security;
7
8 /**
9 * A block cipher is a data encryption algorithm that operates on blocks.
10 */
11 public interface BlockCipher {
12
13 /**
14 * Blocks sizes are always multiples of this number.
15 */
16 int ALIGN = 16;
17
18 /**
19 * Set the encryption key used for encrypting and decrypting.
20 * The key needs to be 16 bytes long.
21 *
22 * @param key the key
23 */
24 void setKey(byte[] key);
25
26 /**
27 * Encrypt a number of bytes. This is done in-place, that
28 * means the bytes are overwritten.
29 *
30 * @param bytes the byte array
31 * @param off the start index
32 * @param len the number of bytes to encrypt
33 */
34 void encrypt(byte[] bytes, int off, int len);
35
36 /**
37 * Decrypt a number of bytes. This is done in-place, that
38 * means the bytes are overwritten.
39 *
40 * @param bytes the byte array
41 * @param off the start index
42 * @param len the number of bytes to decrypt
43 */
44 void decrypt(byte[] bytes, int off, int len);
45
46 /**
47 * Get the length of the key in bytes.
48 *
49 * @return the length of the key
50 */
51 int getKeyLength();
52
53 }