Shiwei Zhang
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Notary V2 - Signature Format ###### tags: `notary` [Notary Issue #86](https://github.com/notaryproject/notaryproject/issues/86) This document defines the requirements of the signature format and discusses the candidates for Notary V2. ## Definition A complete signature $\Sigma = (m, \mu, \hat\mu, \sigma) \gets \mathbf{Sign}(sk, m)$ is a tuple of - Signed payload $m$. - Signed signature metadata $\mu$. - Unsigned signature metadata $\hat\mu$. - Cryptographic signature $\sigma$. where $sk$ stands for signing key. ![A complete signature in OCI registry](https://i.imgur.com/ASv4A6o.png) A signature envelope $\varepsilon_n = \{ m, (\mu_0, \hat\mu_0, \sigma_0), \dots, (\mu_{n-1}, \hat\mu_{n-1}, \sigma_{n-1}) \}$ is a compact form of $n$ signatures signing the same payload $m$. It can be expanded to $\Sigma_i = (m, \mu_i, \hat\mu_i, \sigma_i),\ \forall i \in \mathbb{Z}_n$. A complete signature $\Sigma$ can be viewed as a signature envelope $\varepsilon_1$. ## Requirements Since payload is about the metadata of the artifact manifest to be signed and it is not specific to any signature scheme, the payload requirements are discussed separately. ### Payload - The payload MUST be a byte sequence. - The payload MUST contain a [descriptor](https://github.com/opencontainers/image-spec/blob/master/descriptor.md#properties) of the target manifest. - A descriptor MUST contain `mediaType`, `digest`, `size` fields. - A descriptor MAY contain a `annotations` field. - A descriptor MAY contain the `artifactType` field for artifact manifests, or the `config.mediaType` for `oci.image` based manifests. - Artifact identity MAY be indicated in the payload. - When indicated, the verifier SHOULD verify the origin against the signer. ### Signature - A signature MUST be stored or transferred in a signature envelope. - A signature envelope SHOULD be encoded in a single file. - A signature envelope MUST contain one and only one complete signature. - Multiple signatures for a subject manifest MUST be represented as seperate signature manifest and signature envelope (blob) pairs. - The signing algorithm MAY be indicated in the signed signature metadata. - There is a concern on the signing algorithm not matching the verification key. - See [CS-DRNT15-1 Section 3.3](https://github.com/theupdateframework/notary/blob/master/docs/resources/ncc_docker_notary_audit_2015_07_31.pdf). - Similar vulnerability is introduced in [A cross-protocol attack on the TLS protocol](https://doi.org/10.1145/2382196.2382206) by Mavrogiannopoulos et al. - Detailed discussions can be found at [secure-systems-lab/dsse#35](https://github.com/secure-systems-lab/dsse/issues/35). - The signing timestamp MAY be in the signed signature metadata. - The signature expiry time MAY be in the signed signature metadata. - The signed signature metadata MAY contain information that allows verifiers to determine if the artifact is revoked. - The contents of this attribute are pending the outcome of artifact level revocation design. - If the signature is timestamped by a TSA, the timestamp and the corresponding signatures MUST be stored in the unsigned signature metadata. - If the signature was produced by a X.509 certificate, the signature MUST contain the complete certificate chain of the signing certificate as an unsigned attribute. - The thumbprint of the signing certificate MAY be indicated in the unsigned signature metadata. ### Signature Format - A signature format MUST be able to store the payload. - A signature format MUST be able to store the cryptographic signature. - A signature format MUST be able to store unsigned signature metadata. - _This requirement is essential for TSA._ To time stamp a signature, the original signature must be generated first and then sent to a TSA for time stamping. Once obtained the timestamp signature, it will be attached to the original signature. - A signature format MAY be able to store signed signature metadata. - In case of a signature format candidate being unable to store signed signature metadata, the signed signature metadata can be combined with the payload before signing. Since the payload contains the signature specific metadata, the signature format loses the ability to store multiple signatures. - *Signature format MUST support referencing and inlining of different identity types such as key(s) and certificate(s).* - *Signature format SHOULD be easy to implement using existing Go libraries(Docker CLIs are developed in Go).* - *Signature format MAY be able to store multiple signatures generated using same or different cryptographicmaterials(identity types and signing algoritms).* - *Signature format MAY support counter signature.* ## Existing Formats ### JWT variant Notary v2 `version <= prototype-2` defines a [JWT-variant signature format](https://github.com/notaryproject/nv2/tree/prototype-2/docs/signature). Particularly, this JWT-variant is serialized in JWS Compact Serialization as defined by [RFC7515 Section 7.1](https://datatracker.ietf.org/doc/html/rfc7515#section-7.1). Pros: - Commonly used. - Libraries can be found for many languages. - More flexible. Cons: - Consumes the header before authenticating. - Verifiers can be tricked into MAC algorithms instead of asymmetric key signing. - Example: [RSA or HMAC?](https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/) - This variant may not be compatible with all existing libraries. - Current implementation relies on [docker/libtrust](https://github.com/docker/libtrust), which is archived. - Does not support unsigned signature metadata. - Cannot be extended to support TSA. Example: ``` eyJ0eXAiOiJ4NTA5IiwiYWxnIjoiUlMyNTYiLCJ4NWMiOlsiTUlJRHN6Q0NBcHVnQXdJQkFnSVVMMWFuRVUveUp5NjdWSlRiSGtOWDBiQk5BbkV3RFFZSktvWklodmNOQVFFTEJRQXdhVEVkTUJzR0ExVUVBd3dVY21WbmFYTjBjbmt1WlhoaGJYQnNaUzVqYjIweEZEQVNCZ05WQkFvTUMyVjRZVzF3YkdVZ2FXNWpNUXN3Q1FZRFZRUUdFd0pWVXpFVE1CRUdBMVVFQ0F3S1YyRnphR2x1WjNSdmJqRVFNQTRHQTFVRUJ3d0hVMlZoZEhSc1pUQWVGdzB5TURBM01qY3hORFF6TkRaYUZ3MHlNVEEzTWpjeE5EUXpORFphTUdreEhUQWJCZ05WQkFNTUZISmxaMmx6ZEhKNUxtVjRZVzF3YkdVdVkyOXRNUlF3RWdZRFZRUUtEQXRsZUdGdGNHeGxJR2x1WXpFTE1Ba0dBMVVFQmhNQ1ZWTXhFekFSQmdOVkJBZ01DbGRoYzJocGJtZDBiMjR4RURBT0JnTlZCQWNNQjFObFlY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0fG3Xgy8yekdB9NMUn+zZLATI4+z8j4QH5Wj5ZPaUkyoAD2oUJO" ] }.{ "mediaType": "application/vnd.docker.distribution.manifest.v2+json", "digest": "sha256:c4516b8a311e85f1f2a60573abf4c6b740ca3ade4127e29b05616848de487d34", "size": 528, "references": [ "registry.example.com/example:latest", "registry.example.com/example:v1.0" ], "exp": 1628587119, "iat": 1597051119, "nbf": 1597051119 }.[Signature] ``` ### JWS JSON Serialization General JWS JSON serialization syntax is defined in [RFC7515 Section 7.2.1](https://datatracker.ietf.org/doc/html/rfc7515#section-7.2.1). Pros: - Well defined in [RFC7515](https://datatracker.ietf.org/doc/html/rfc7515), [RFC7518](https://www.rfc-editor.org/rfc/rfc7518), [RFC7519](https://datatracker.ietf.org/doc/html/rfc7519) Cons: - [Security concerns](https://github.com/secure-systems-lab/dsse/blob/master/background.md#motivation) on payload type. - Resolved by signing [cty](https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.10) header. Here is an example: Payload: ```json { "mediaType": "application/vnd.docker.distribution.manifest.v2+json", "size": 525, "digest": "sha256:1b26826f602946860c279fce658f31050cff2c596583af237d971f4629b57792", "annotations": { "notary.v2.identity": "registry.wabbit.net/hello-world:1.0" } } ``` Signed signature metadata: ```json { "alg": "RS256", "arl": "http://registry.wabbit.net/arl", "exp": "2021-09-20T16:02:40.3375379Z", "iat": "2021-06-22T16:02:40.3375379Z" } ``` Complete JWS JSON Serialization: ```json { "payload": "ewogICAgIm1lZGlhVHlwZSI6ICJhcHBsaWNhdGlvbi92bmQuZG9ja2VyLmRpc3RyaWJ1dGlvbi5tYW5pZmVzdC52Mitqc29uIiwKICAgICJzaXplIjogNTI1LAogICAgImRpZ2VzdCI6ICJzaGEyNTY6MWIyNjgyNmY2MDI5NDY4NjBjMjc5ZmNlNjU4ZjMxMDUwY2ZmMmM1OTY1ODNhZjIzN2Q5NzFmNDYyOWI1Nzc5MiIsCiAgICAiYW5ub3RhdGlvbnMiOiB7CiAgICAgICAgIm5vdGFyeS52Mi5pZGVudGl0eSI6ICJyZWdpc3RyeS53YWJiaXQubmV0L2hlbGxvLXdvcmxkOjEuMCIKICAgIH0KfQ", "signatures": [ { "protected": "ewogICAgImFsZyI6ICJSUzI1NiIsCiAgICAiYXJsIjogImh0dHA6Ly9yZWdpc3RyeS53YWJiaXQubmV0L2FybCIsCiAgICAiZXhwIjogIjIwMjEtMDktMjBUMTY6MDI6NDAuMzM3NTM3OVoiLAogICAgImlhdCI6ICIyMDIxLTA2LTIyVDE2OjAyOjQwLjMzNzUzNzlaIgp9Cg", "header": { "kid": "906ade40b96cff95e5b60f7e96f2cda7979c8ad5", "timestamp": "TimeStampToken/in/base64" }, "signature": "r5ANOfLzS30CFId49egGiIQWcC-G_tX5dhsswigOUAGq1L2MIfuvV2xn4u8M33CJIbOM2e3doJSwdD6mI51y6A" } ] } ``` If a JWS contains only one signature as above, the JWS can be flattened as ```json { "payload": "ewogICAgIm1lZGlhVHlwZSI6ICJhcHBsaWNhdGlvbi92bmQuZG9ja2VyLmRpc3RyaWJ1dGlvbi5tYW5pZmVzdC52Mitqc29uIiwKICAgICJzaXplIjogNTI1LAogICAgImRpZ2VzdCI6ICJzaGEyNTY6MWIyNjgyNmY2MDI5NDY4NjBjMjc5ZmNlNjU4ZjMxMDUwY2ZmMmM1OTY1ODNhZjIzN2Q5NzFmNDYyOWI1Nzc5MiIsCiAgICAiYW5ub3RhdGlvbnMiOiB7CiAgICAgICAgIm5vdGFyeS52Mi5pZGVudGl0eSI6ICJyZWdpc3RyeS53YWJiaXQubmV0L2hlbGxvLXdvcmxkOjEuMCIKICAgIH0KfQ", "protected": "ewogICAgImFsZyI6ICJSUzI1NiIsCiAgICAiYXJsIjogImh0dHA6Ly9yZWdpc3RyeS53YWJiaXQubmV0L2FybCIsCiAgICAiZXhwIjogIjIwMjEtMDktMjBUMTY6MDI6NDAuMzM3NTM3OVoiLAogICAgImlhdCI6ICIyMDIxLTA2LTIyVDE2OjAyOjQwLjMzNzUzNzlaIgp9Cg", "header": { "kid": "906ade40b96cff95e5b60f7e96f2cda7979c8ad5", "timestamp": "TimeStampToken/in/base64" }, "signature": "r5ANOfLzS30CFId49egGiIQWcC-G_tX5dhsswigOUAGq1L2MIfuvV2xn4u8M33CJIbOM2e3doJSwdD6mI51y6A" } ``` ### Dead Simple Signature Envelope (DSSE) in-toto enhancement (ITE-5) introduces a [SSL signing spec](https://github.com/secure-systems-lab/signing-spec). This spec is inspired by [PASETO](https://github.com/paragonie/paseto), which is too opinionated. Later, this spec is evolved to [Dead Simple Signature Envelope (DSSE)](https://github.com/secure-systems-lab/dsse) with its [PAE()](https://github.com/secure-systems-lab/dsse/blob/master/protocol.md#signature-definition) function updated. Pros: - Simple. - Security decisions only depends on the authenticated fields. Cons: - Less common. - Need to find the suitable algorithm according to the known keys by brute force Example: ```json { "payload": "aGVsbG8gd29ybGQ=", "payloadType": "http://example.com/HelloWorld", "signatures": [ { "keyid": "key id is optional", "sig": "y7BK8Mm8Mr4gxk4+G9X3BD1iBc/vVVuJuV4ubmsEK4m/8MhQOOS26ejx+weIjyAx8VjYoZRPpoXSNjHEzdE7nQ==" } ] } ``` ### Red Hat's Simple Signing Red Hat's [simple signing](https://www.redhat.com/en/blog/container-image-signing) format is intended for payloads. The payload format is adapted by `atomic` and later by [cosign](https://github.com/sigstore/cosign). ```json { "critical": { "identity": { "docker-reference": "testing/manifest" }, "image": { "Docker-manifest-digest": "sha256:20be...fe55" }, "type": "atomic container signature" }, "optional": { "creator": "atomic", "timestamp": 1458239713 } } ``` It is a payload format not a signature format. ### PKCS #7: Cryptographic Message Syntax (CMS) PKCS #7: CMS is defined in [RFC2315](https://datatracker.ietf.org/doc/html/rfc2315) and updated by [RFC5652](https://datatracker.ietf.org/doc/html/rfc5652). The CMS is widely used for general digital signatures. For instances, [RFC8551](https://datatracker.ietf.org/doc/html/rfc8551), [NuGet.org](https://devblogs.microsoft.com/nuget/introducing-repository-signatures/). The signature is stored in asn.1 DER binary format and optionally wrapped in PEM blocks. *Go Library: https://pkg.go.dev/go.mozilla.org/pkcs7* Pros: - Mature standard - Build-in signature attribute support - Build-in TSA support - Build-in CRL support Cons: - Lack of stable Go library - Only supports certificates - Many implementation only support X.509 certificates such as .net. ## Recommendation It is recommended to reuse existing signature format according the requirements. If there is no suitable candidate, extend the existing signature format for minimum viable product. If non of above meet the requirements, we may consider to design a new signature format. ### JWS JSON Serialization JWS JSON serialization meets our requirements. Golang implementation is possible by combining - [github.com/golang-jwt/jwt](https://github.com/golang-jwt/jwt) for signing / verifying JWT tokens. - [github.com/shizhMSFT/go-jwsutil](https://github.com/shizhMSFT/go-jwsutil) for JWS compact / JSON serialization conversion. - [github.com/shizhMSFT/go-timestamp](https://github.com/shizhMSFT/go-timestamp) for timestamp request. - [github.com/cloudflare/cfssl/crypto/pkcs7](https://github.com/cloudflare/cfssl/blob/master/crypto/pkcs7/pkcs7.go) for timestamp verification. - Need ASN.1 BER to DER conversion. ### Example by extending DSSE The format is proposed by extending DSSE. Payload: ```json { "mediaType": "application/vnd.docker.distribution.manifest.v2+json", "size": 525, "digest": "sha256:1b26826f602946860c279fce658f31050cff2c596583af237d971f4629b57792", "annotations": { "notary.v2.identity": "registry.wabbit.net/hello-world:1.0" } } ``` Signed signature metadata: ```json { "alg": "RS256", "arl": "http://registry.wabbit.net/arl", "exp": "2021-09-20T16:02:40.3375379Z", "iat": "2021-06-22T16:02:40.3375379Z" } ``` Signature envelope: ```json { "payload": "ewogICAgIm1lZGlhVHlwZSI6ICJhcHBsaWNhdGlvbi92bmQuZG9ja2VyLmRpc3RyaWJ1dGlvbi5tYW5pZmVzdC52Mitqc29uIiwKICAgICJzaXplIjogNTI1LAogICAgImRpZ2VzdCI6ICJzaGEyNTY6MWIyNjgyNmY2MDI5NDY4NjBjMjc5ZmNlNjU4ZjMxMDUwY2ZmMmM1OTY1ODNhZjIzN2Q5NzFmNDYyOWI1Nzc5MiIsCiAgICAiYW5ub3RhdGlvbnMiOiB7CiAgICAgICAgIm5vdGFyeS52Mi5pZGVudGl0eSI6ICJyZWdpc3RyeS53YWJiaXQubmV0L2hlbGxvLXdvcmxkOjEuMCIKICAgIH0KfQ==", "payloadType": "application/vnd.cncf.notary.v2.descriptor", "signatures": [ { "keyid": "906ade40b96cff95e5b60f7e96f2cda7979c8ad5", "metadata": "ewogICAgImFsZyI6ICJSUzI1NiIsCiAgICAiYXJsIjogImh0dHA6Ly9yZWdpc3RyeS53YWJiaXQubmV0L2FybCIsCiAgICAiZXhwIjogIjIwMjEtMDktMjBUMTY6MDI6NDAuMzM3NTM3OVoiLAogICAgImlhdCI6ICIyMDIxLTA2LTIyVDE2OjAyOjQwLjMzNzUzNzlaIgp9Cg==", "timestamp": "TimeStampToken/in/base64", "sig": "pi6YujSNkb4X1h81++AQpchnCEz9gtVXGICq/VG+4B1b8BemrVN18jRymesq9DEATHvIBJzvIK2OaLxKlZufdg==" } ] } ``` ----- ### [PB]Example using JWS JSON Serialization The format is proposed using JWS JSON Serialization. **Payload:** ```json { "notary.v2": { "subjectManifest": { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:73c803930ea3ba1e54bc25c2bdc53edd0284c62ed651fe7b00369da519a3c333", "size": 16724, "annotations": { "org.acme-rockets.importDate": "2021-04-23T18:25:43.511Z" } }, "signedAttrs": { "reserved": { "arl": "http://registry.wabbit.net/arl", "identity": "acme-rockets.io/net-monitor:v1" }, "custom" : { "buildId": "0001", "imageScanned": "true" } } }, "iat": "2021-06-22T16:02:40.3375379Z", "exp": "2021-09-20T16:02:40.3375379Z" } ``` Payload contain the subject manifest and other attributes that has to be integrity protected. * `notary.v2`: Top level node and private claim, encapsulating the notary v2 data. * In order to leverage JWS claims functionality provided by libraries we have defined `iat`, `exp` as top level nodes. * `subjectManifest`: The image manifest that needs to be integrity protected. * `signedAttrs`: The additional metadata that needs to be signed. * `reserved`: The signed attributes reserved for notary v2 use such as issuedAt(iat), expiration Time(exp), artifact revocation list(arl), etc. * `custom`: The user defined signed attributes such as buildId, imageScanned, etc. * To start with we will only support iat, exp and notary.v2 claim. PB[add required and optional claims] **ProtectedHeader:** ```json { "alg": "RS256", "cty": "application/<TBD>" } ``` * JWS needs alogrithm(alg) to be present in header so we have added it as protected header. * `cty`: Content type used to declare the media type of the secured content(the payload) **SignatureEnvelope:** ```json { "payload": "<Base64Url(Payload)>", "protected": "<Base64Url(ProtectedHeader)>" "header": { "timestamp": "<Base64Url(TimeStampToken)>", "kid": "906ade40b96cff95e5b60f7e96f2cda7979c8ad5", "x5c": ["<Base64(DER(leafCert))>", "<Base64(DER(intermediateCACert))>", "<Base64(DER(rootCert))>"] }, "signature": "Base64Url( sign( ASCII( <Base64Url(Payload)>.<Base64Url(ProtectedHeader)> )))" } ``` * `protected`: Base64Url encoded JSON object that contains the header parameters that are integrity protected by the JWS Signature digital signature * `header`: JOSE Header containing the parameters describing the cryptographic operations and parameters employed. header is not integrety protected by signature. To start with we will only support reserved set of headers. TODO: Fail the signature if contains extra header? * `timestamp`: Base64Url encoded [timestamp token](https://datatracker.ietf.org/doc/html/rfc3161#section-2.4.2) generated by TSA. * `kid` Hint indicating which key was used to generate the signature. * `x5c` contains the X.509 public key certificate or certificate chain corresponding to the key used to used to generate the signature. If signature was generated by x509 certificate signature envelop must contain x5c * In case of `x5c` the leaf certificate's signing algorithm(with some additional conventions [TODO: add convention]) will be used for signature and this algorithm will be value of `alg` header. The verifier will make sure that the value of `alg` is same as that of leaf certificate's signing algorithm. ### [PB] Example using DSSE The format is proposed using extended version of DSSE. **Payload:** ```json { "subjectManifest": { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:73c803930ea3ba1e54bc25c2bdc53edd0284c62ed651fe7b00369da519a3c333", "size": 16724, "annotations": { "org.acme-rockets.importDate": "2021-04-23T18:25:43.511Z" } }, "signedAttrs": { "reserved": { "iat": "2021-06-22T16:02:40.3375379Z", "exp": "2021-09-20T16:02:40.3375379Z", "arl": "http://registry.wabbit.net/arl", "identity": "acme-rockets.io/net-monitor:v1" }, "custom" : { "BuildId": "0001", "imageScanned": "true" } } } ``` **SignatureEnvelope:** ```json { "payload": "<Base64(Payload)>", "payloadType": "application/<TBD>", "signatures": [ { "keyid": "906ade40b96cff95e5b60f7e96f2cda7979c8ad5", "x5c": ["<Base64(DER(leafCert))>", "<Base64(DER(intermediateCACert))>", "<Base64(DER(rootCert))>"], "timestamp": "<Base64(TimeStampToken)>", "sig": "Base64( sign( <Base64(Payload)> ))" } ] } ``` In SignatureEnvelope's `signatures` node user can either specify keyid or x5c. Currently DSSE doesn't support timestamp and x5c fields. ### Open Questions 1. In Payload do we need `subjectManifest#annotations`? As we have already defined `signedAttrs#custom` node for user specific metadata? 2. Should signature varification fail if signature envelop contains unsupported fields? ## Prototype scope [Draft] - Prototype - Use defined payload format - Verify including - Cert chain validation - Exclude revocation check - TSA signature - Signature expiry - ARL field (placeholder) - Exclude ARL check - Custom signed attributes (wrapped payload) - Types of keys (different x5c) - RSA - ECDSA - EdDSA? ## References - [Notary Security Topics](https://hackmd.io/9mc_kvXoRc2GmjOnz0_eYA?view) - [Notary V2 - Rescinding Signatures](https://hackmd.io/2rc07WwHTdmPjpgoMbvYfA?view) - [Notary V2 - More Signature Format Examples](https://hackmd.io/0GKGd0-1QQirbe1yty5vPg?view) - [Signature Samples from Prototypes](https://hackmd.io/V7-71xB_R5-k8UrdNdhlBg?view)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully