Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame^] | 1 | package eu.mulk.jgvariant.ostree; |
| 2 | |
| 3 | import eu.mulk.jgvariant.core.Decoder; |
| 4 | import eu.mulk.jgvariant.core.Variant; |
| 5 | import java.nio.ByteOrder; |
| 6 | import java.nio.charset.StandardCharsets; |
| 7 | import 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 | */ |
| 14 | public 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 | } |