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

reader.js is not reading the TAG correctly #50

Open
jtgrant65 opened this issue Jul 20, 2022 · 0 comments
Open

reader.js is not reading the TAG correctly #50

jtgrant65 opened this issue Jul 20, 2022 · 0 comments

Comments

@jtgrant65
Copy link

I am writing a lambda function in aws using node.js to ssh to an ec2 instance. I want to use public key private key pairs so I don't have to embed a password in the code. I'm using simple-ssh as a wrapper library to ssh2 which in turn calls asn1 reader.js to parse the private key to verify its validity. There appears to be a problem with indexing through the first 8 bytes of the key which manifests itself in the method readString. The first 8 bytes are as follows: 30 82 04 bd 02 01 00 30. By the time readSting is called, the offset variable is 7 which causes the code to read the 8th byte which is 0x30. readString compares this value with the TAG value which is 0x02 and throws an error stating that the key is invalid because 0x30 doesn't match 0x02. If I load my private key into this website https://lapo.it/asn1js/ it can parse the key without fail. I also found some javascript code that also is consistent with how the first 8 bytes are indexed and successfully parses the key. I think that the offsets are being handled incorrectly in the code.

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