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

Please provide documentation for the pkcs8 related constants in keyring #1908

Closed
1 of 4 tasks
clearloop opened this issue Jan 4, 2024 · 2 comments
Closed
1 of 4 tasks

Comments

@clearloop
Copy link

clearloop commented Jan 4, 2024

Documentation requests

  • Bug report
  • Feature request
  • Support request
  • Other
  • What is the current behavior and expected behavior?

export const PKCS8_DIVIDER = new Uint8Array([161, 35, 3, 33, 0]);
export const PKCS8_HEADER = new Uint8Array([48, 83, 2, 1, 1, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]);

// review: where are these bytes from, what's the exact meaning of them
export const PKCS8_DIVIDER = new Uint8Array([161, 35, 3, 33, 0]);
// review: same
export const PKCS8_HEADER = new Uint8Array([48, 83, 2, 1, 1, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]);

the header and divider here seems not following the private key information syntax defined in RFC5208-section-5

PrivateKeyInfo ::= SEQUENCE {
        version                   Version,
        privateKeyAlgorithm       PrivateKeyAlgorithmIdentifier,
        privateKey                PrivateKey,
        attributes           [0]  IMPLICIT Attributes OPTIONAL }

Version ::= INTEGER
PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
PrivateKey ::= OCTET STRING
Attributes ::= SET OF Attribute

both encode and decode methods are using these constants without any description, no tests provided, just hardcode bytes level checks

const encoded = u8aConcat(
PKCS8_HEADER,
secretKey,
PKCS8_DIVIDER,
publicKey
);

if (!u8aEq(header, PKCS8_HEADER)) {
throw new Error('Invalid Pkcs8 header found in body');
}

@jacogr
Copy link
Member

jacogr commented Jan 9, 2024

Closed in #1910 - be aware that these constants should not be relied upon, only the exposed interfaces for decode/encode, it is bound to change.

(There are still a large number of files which have not been commented, in this repo and others - especially on types, it is a "ahh, this needs work and I'm here" effort)

@jacogr jacogr closed this as completed Jan 9, 2024
@polkadot-js-bot
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Jan 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants