Code Monkey home page Code Monkey logo

Comments (3)

sarroutbi avatar sarroutbi commented on July 3, 2024

Sorry, I don't understand what you mean by a "valid advertisement payload". The files that are generated by tang are done in the way you specified.

Apart from that, tang uses a SHA mechanism to get the file names used by tang. This is done by using "jose jwk thp"

But the content is generated similarly to the way you specified.

If you check the file ./src/tangd-rotate-keys.in, you can check how the keys are rotated (which in the end is a move + new key generation):

    DEFAULT_THP_HASH="S256"                                                     
    for alg in "ES512" "ECMR"; do                                               
        json="$(printf '{"alg": "%s"}' "${alg}")"                               
        jwe="$(jose jwk gen --input "${json}")"                                 
        thp="$(printf '%s' "${jwe}" | jose jwk thp --input=- \                  
                                           -a "${DEFAULT_THP_HASH}")"           
        echo "${jwe}" > "${thp}.jwk"                                            
        set_perms "${thp}.jwk"                                                  
        log "Created new key ${thp}.jwk" "${VERBOSE}"                           
    done  

As you can see, "jose jwk gen --input" is used (similar to what you posted), and the file name is calculated passing that output to "jose jwk thp --input=- -a S256"

Hope this helps

from tang.

olastor avatar olastor commented on July 3, 2024

@sarroutbi Thank you for your reply!

Sorry, I don't understand what you mean by a "valid advertisement payload".

Sorry, my explanation was probably not detailed enough. I am trying to generate the keys offline as well as what is returned by "http://<TANG_URL>/adv" with jose so that I would be able to use clevis with the tang pin even before the tang server was created.

If you check the file ./src/tangd-rotate-keys.in, you can check how the keys are rotated (which in the end is a move + new key generation):

Thanks for that pointer about the file names!

from tang.

olastor avatar olastor commented on July 3, 2024

I've figured it out. The advertisement seems to be a payload of the form { "keys": [<signing-public-key>, <exchange-public-key>] } that is signed with the signing private key. The public keys can be derived from the keys in /var/db/tang, e.g., cat <keyfile> | jose jwk pub -i - -o - and the payload can then be signed, e.g. echo "${payload}" | jose jws sig -k <priv-sig-keyfile> -I - -o -. The output should be valid to use with clevis with the "adv" field to make offline encryption work.

from tang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.