Skip to content

try to support pkcs8 v2 format pem file for EdDSA #281

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

Merged
merged 3 commits into from
Jan 4, 2022

Conversation

Myse1f
Copy link
Contributor

@Myse1f Myse1f commented Dec 27, 2021

Try to fix #280.

RFC5958 shows that pkcs8 v2 has the format:

OneAsymmetricKey ::= SEQUENCE {
       version                   Version,
       privateKeyAlgorithm       PrivateKeyAlgorithmIdentifier,
       privateKey                PrivateKey,
       attributes            [0] Attributes OPTIONAL,
       ...,
       [[2: publicKey        [1] PublicKey OPTIONAL ]],
       ...
}

There are maybe optional Attributes and Publickey after Privatekey. Thus it may not raise error when there are trailing data.

@Myse1f
Copy link
Contributor Author

Myse1f commented Dec 28, 2021

For ed25519 and ed448 in RFC5958, I think it should not raise error if something left after private key.

@Myse1f Myse1f changed the title try to support pkcs8 v2 format pem file try to support pkcs8 v2 format pem file for EdDSA Dec 28, 2021
@tomato42
Copy link
Member

tomato42 commented Jan 3, 2022

Change looks good but there are few nits reported by codechecks, could you fix them?:

tox -e codechecks
GLOB sdist-make: /home/runner/work/python-ecdsa/python-ecdsa/setup.py
codechecks create: /home/runner/work/python-ecdsa/python-ecdsa/.tox/codechecks
codechecks installdeps: black==19.10b0, flake8
codechecks inst: /home/runner/work/python-ecdsa/python-ecdsa/.tox/.tmp/package/1/ecdsa-0.18.0b1+13.g8658d14.zip
codechecks installed: appdirs==1.4.4,attrs==21.4.0,black==19.10b0,click==8.0.3,ecdsa @ file:///home/runner/work/python-ecdsa/python-ecdsa/.tox/.tmp/package/1/ecdsa-0.18.0b1%2B13.g8658d14.zip,flake8==4.0.1,mccabe==0.6.1,pathspec==0.9.0,pycodestyle==2.8.0,pyflakes==2.4.0,regex==2021.11.10,six==1.16.0,toml==0.10.2,typed-ast==1.5.1
codechecks run-test-pre: PYTHONHASHSEED='3772385342'
codechecks run-test: commands[0] | flake8 setup.py speed.py src
src/ecdsa/keys.py:1127:1: W293 blank line contains whitespace
src/ecdsa/keys.py:1128:76: W291 trailing whitespace
src/ecdsa/keys.py:1129:70: W291 trailing whitespace
src/ecdsa/keys.py:1131:1: W293 blank line contains whitespace

@Myse1f
Copy link
Contributor Author

Myse1f commented Jan 3, 2022

Of course

Change looks good but there are few nits reported by codechecks, could you fix them?:

tox -e codechecks
GLOB sdist-make: /home/runner/work/python-ecdsa/python-ecdsa/setup.py
codechecks create: /home/runner/work/python-ecdsa/python-ecdsa/.tox/codechecks
codechecks installdeps: black==19.10b0, flake8
codechecks inst: /home/runner/work/python-ecdsa/python-ecdsa/.tox/.tmp/package/1/ecdsa-0.18.0b1+13.g8658d14.zip
codechecks installed: appdirs==1.4.4,attrs==21.4.0,black==19.10b0,click==8.0.3,ecdsa @ file:///home/runner/work/python-ecdsa/python-ecdsa/.tox/.tmp/package/1/ecdsa-0.18.0b1%2B13.g8658d14.zip,flake8==4.0.1,mccabe==0.6.1,pathspec==0.9.0,pycodestyle==2.8.0,pyflakes==2.4.0,regex==2021.11.10,six==1.16.0,toml==0.10.2,typed-ast==1.5.1
codechecks run-test-pre: PYTHONHASHSEED='3772385342'
codechecks run-test: commands[0] | flake8 setup.py speed.py src
src/ecdsa/keys.py:1127:1: W293 blank line contains whitespace
src/ecdsa/keys.py:1128:76: W291 trailing whitespace
src/ecdsa/keys.py:1129:70: W291 trailing whitespace
src/ecdsa/keys.py:1131:1: W293 blank line contains whitespace

@Myse1f
Copy link
Contributor Author

Myse1f commented Jan 3, 2022

Furthemore, I want to know if you have rough plan to release version 0.18.0. Then I could use the function for EdDSA.

@tomato42
Copy link
Member

tomato42 commented Jan 3, 2022

Furthemore, I want to know if you have rough plan to release version 0.18.0. Then I could use the function for EdDSA.

"when it's done", at the minimum, fixing the #268 and finishing #256 (adding interoperability testing with OpenSSL) needs to happen

@tomato42
Copy link
Member

tomato42 commented Jan 3, 2022

black part of codechecks is still failing, you should be able to fix it with tox -e codeformat

@Myse1f
Copy link
Contributor Author

Myse1f commented Jan 4, 2022

I think it should be fixed now.

@tomato42
Copy link
Member

tomato42 commented Jan 4, 2022

Yup, looks good. Thanks!

@tomato42 tomato42 merged commit 065b40c into tlsfuzzer:master Jan 4, 2022
@tomato42 tomato42 added the bug unintended behaviour in ecdsa code label Jan 4, 2022
@tomato42 tomato42 added this to the v0.18.0 milestone Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unintended behaviour in ecdsa code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SigningKey.from_pem may not support pkcs#8 v2
2 participants