blob: 2fc5c25673715874551fffdffa2779ddc3eda7b0 [file] [log] [blame]
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +01001package eu.mulk.jgvariant.ostree;
2
3import eu.mulk.jgvariant.core.Decoder;
4import eu.mulk.jgvariant.core.Variant;
5import java.nio.ByteOrder;
6import java.nio.charset.StandardCharsets;
7import java.util.List;
8
9/**
10 * A {@link DeltaSuperblock} signed with some sort of key.
11 *
12 * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_SIGNED_FORMAT}
13 */
14public record SignedDelta(
15 long magicNumber, ByteString superblock, List<SignedDelta.Signature> signatures) {
16
17 /** A cryptographic signature. */
18 public record Signature(String key, Variant data) {
19 private static final Decoder<Signature> DECODER =
20 Decoder.ofStructure(
21 Signature.class, Decoder.ofString(StandardCharsets.US_ASCII), Decoder.ofVariant());
22
23 public static Decoder<Signature> decoder() {
24 return DECODER;
25 }
26 }
27
28 private static final Decoder<SignedDelta> DECODER =
29 Decoder.ofStructure(
30 SignedDelta.class,
31 Decoder.ofLong().withByteOrder(ByteOrder.BIG_ENDIAN),
32 ByteString.decoder(),
33 Decoder.ofArray(Signature.decoder()));
34
35 public static Decoder<SignedDelta> decoder() {
36 return DECODER;
37 }
38}