Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get publicKey from cert #155

Open
lpinkas-ecosistemas opened this issue Jun 8, 2023 · 0 comments
Open

Get publicKey from cert #155

lpinkas-ecosistemas opened this issue Jun 8, 2023 · 0 comments

Comments

@lpinkas-ecosistemas
Copy link

Hello and first of all thank you for this amazing package!
I need help signing and verifying with the provided cert and private key, which are already configured in the token (safenet 5110 etoken).
I already managed to sign using the private key identifier, but I can't figure out how to get the public key from the certificate to verify the signature.

const privateKeys = session.find({
        class: graphene.ObjectClass.PRIVATE_KEY,
      });
      const privateKey = privateKeys.items(0);
      const sign = session.createSign('SHA256_RSA_PKCS', privateKey);
      sign.update('simple text 1');
      sign.update('simple text 2');
      const signature = sign.final();
      console.log('Signature RSA-SHA1:', signature.toString('hex')); // Signature RSA-SHA1: 6102a66dc0d97fadb5...

var verify = session.createVerify("SHA256_RSA_PKCS", ?????????);
      verify.update("simple text 1");
      verify.update("simple text 2");
      var verify_result = verify.final(signature);
      console.log("Signature RSA-SHA1 verify:", verify_result);      // Signature RSA-SHA1 verify: true

Any help would be greatly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant