aboutsummaryrefslogtreecommitdiffstats
path: root/security-utils/src/main/java/com/yahoo/security/hpke/Constants.java
blob: bfd810c10d28221f3d80cb5f53ffc9b19077340b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.security.hpke;

import com.yahoo.security.ArrayUtils;

/**
 * Various internal constants used as part of key derivation etc. in HPKE
 *
 * @author vekterli
 */
final class Constants {

    private static byte[] toBytes(String str) {
        return ArrayUtils.toUtf8Bytes(str); // We only expect US-ASCII in practice, so UTF-8 is fine.
    }

    static final byte[] HPKE_V1_LABEL       = toBytes("HPKE-v1");
    static final byte[] EMPTY_LABEL         = new byte[0];
    static final byte[] EAE_PRK_LABEL       = toBytes("eae_prk");
    static final byte[] SHARED_SECRET_LABEL = toBytes("shared_secret");

    /**
     * <pre>
     * default_psk = ""
     * default_psk_id = ""
     * </pre>
     */
    static final byte[] DEFAULT_PSK    = new byte[0];
    static final byte[] DEFAULT_PSK_ID = new byte[0];

    static final byte[] PSK_ID_HASH_LABEL = toBytes("psk_id_hash");
    static final byte[] INFO_HASH_LABEL   = toBytes("info_hash");
    static final byte[] SECRET_LABEL      = toBytes("secret");
    static final byte[] KEY_LABEL         = toBytes("key");
    static final byte[] BASE_NONCE_LABEL  = toBytes("base_nonce");
    static final byte[] EXP_LABEL         = toBytes("exp");

}