Skip to content

Commit 37deb42

Browse files
committed
export user-visible exceptions in primary module
since MalformedPointError and UnexpectedDER are user-visible (thrown by methods that users are expected to use), export them in the root of the module hierarchy
1 parent d6edd40 commit 37deb42

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ is to call `s=sk.to_string()`, and then re-create it with
123123
`SigningKey.from_string(s, curve)` . This short form does not record the
124124
curve, so you must be sure to tell from_string() the same curve you used for
125125
the original key. The short form of a NIST192p-based signing key is just 24
126-
bytes long.
126+
bytes long. If a point encoding is invalid or it does not lie on the specified
127+
curve, `from_string()` will raise MalformedPointError.
127128

128129
```python
129130
from ecdsa import SigningKey, NIST384p
@@ -139,7 +140,8 @@ formats that OpenSSL uses. The PEM file looks like the familiar ASCII-armored
139140
is a shorter binary form of the same data.
140141
`SigningKey.from_pem()/.from_der()` will undo this serialization. These
141142
formats include the curve name, so you do not need to pass in a curve
142-
identifier to the deserializer.
143+
identifier to the deserializer. In case the file is malformed `from_der()`
144+
and `from_pem()` will raise UnexpectedDER or MalformedPointError.
143145

144146
```python
145147
from ecdsa import SigningKey, NIST384p

src/ecdsa/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from .keys import SigningKey, VerifyingKey, BadSignatureError, BadDigestError
1+
from .keys import SigningKey, VerifyingKey, BadSignatureError, BadDigestError,\
2+
MalformedPointError
23
from .curves import NIST192p, NIST224p, NIST256p, NIST384p, NIST521p, SECP256k1
4+
from .der import UnexpectedDER
35

46
# This code comes from https://github.com/warner/python-ecdsa
57
from ._version import get_versions
@@ -10,5 +12,6 @@
1012
"test_pyecdsa", "util", "six"]
1113

1214
_hush_pyflakes = [SigningKey, VerifyingKey, BadSignatureError, BadDigestError,
15+
MalformedPointError, UnexpectedDER,
1316
NIST192p, NIST224p, NIST256p, NIST384p, NIST521p, SECP256k1]
1417
del _hush_pyflakes

0 commit comments

Comments
 (0)