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

crypto: KeyObject.asymmetricKeySize API #26387

Closed
wants to merge 1 commit into from
Closed

Conversation

paroga
Copy link
Contributor

@paroga paroga commented Mar 2, 2019

Expose the size of asymetric keys of crypto key object from the
crypto module added in v11.6.0 (#24234)

Refs: #24234

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Mar 2, 2019
doc/api/crypto.md Outdated Show resolved Hide resolved
doc/api/crypto.md Outdated Show resolved Hide resolved
Expose the size of asymetric keys of crypto key object from the
crypto module added in v11.6.0 (nodejs#24234)
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM. CI: https://ci.nodejs.org/job/node-test-pull-request/21140/

Maybe a minor suggestion vis-a-vis the commit log summary: crypto: add KeyObject.asymmetricKeySize?

The link to the issue should be Fixes: https://github.com/nodejs/node/pull/24234 on its own line.

edit: make that Refs: https://github.com/nodejs/node/pull/24234

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 6, 2019
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Mar 6, 2019
Expose the size of asymetric keys of crypto key object from the
crypto module added in v11.6.0.

PR-URL: nodejs#26387
Refs: nodejs#24234
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@BridgeAR
Copy link
Member

BridgeAR commented Mar 6, 2019

Landed in 4895927 🎉

I updated the commit message while landing as suggested.

@BridgeAR BridgeAR closed this Mar 6, 2019
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Mar 12, 2019
Expose the size of asymetric keys of crypto key object from the
crypto module added in v11.6.0.

PR-URL: nodejs#26387
Refs: nodejs#24234
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@panva
Copy link
Member

panva commented Mar 13, 2019

👋 Maybe i'm missing something but EVP_PKEY_size returns the maximum signature size in bytes, not the actual key size.

This is apparent with Ed25519 and Ed448 and possibly EC keys as well.

pem =`-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAEXRYV3v5ucrHVR3mKqyPXxXqU34lASwc7Y7MoOvaqcs=\n-----END PUBLIC KEY-----`
k=crypto.createPublicKey(pem)
// PublicKeyObject { [Symbol(kKeyType)]: 'public' }
k.asymmetricKeyType
// 'ed25519'
k.asymmetricKeySize
// 114

114 bytes is the length of a signature, key is in fact 57 bytes

@mscdex
Copy link
Contributor

mscdex commented Mar 13, 2019

@panva That's probably worth posting a new issue for.

@panva
Copy link
Member

panva commented Mar 13, 2019

Will do, wanted to check first if i missed something

@panva
Copy link
Member

panva commented Mar 13, 2019

created #26631

@paroga paroga deleted the aks branch March 13, 2019 13:19
@paroga
Copy link
Contributor Author

paroga commented Mar 13, 2019

i only checked it with RSA, since there are only RSA tests for the KeyObject in the repository. Maybe we should just rename the property and/or change the documentation, to match the returned value

@tniessen tniessen added the semver-minor PRs that contain new features and should be released in the next minor version. label Mar 13, 2019
@tniessen
Copy link
Member

I'm assuming this should have been marked as semver-minor.

BridgeAR added a commit that referenced this pull request Mar 13, 2019
Notable Changes

* build:
  * Enable v8's siphash for hash seed creation (Rod Vagg)
    #26367
* crypto:
  * Add `KeyObject.asymmetricKeySize` (Patrick Gansterer)
    #26387
* deps:
  * Upgrade openssl to 1.1.1b (Sam Roberts)
    #26327
* process:
  * Make `process[Symbol.toStringTag]` writable again
    (Ruben Bridgewater) #26488
* repl:
  * Add `util.inspect.replDefaults` to customize the writer
    (Ruben Bridgewater) #26375
* report:
  * Rename `triggerReport()` to `writeReport()` (Colin Ihrig)
    #26527
@BridgeAR
Copy link
Member

I'll back out this PR from v11.12.0 due to the concerns by @tniessen. If this should indeed land in a PR, please update the labels accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants