Skip to content

Commit

Permalink
#221 - added curve classes for X25519/Ed25519 so that PGPy can suppor…
Browse files Browse the repository at this point in the history
…t it as soon as people obtain builds of OpenSSL that include support for them
  • Loading branch information
Commod0re committed Nov 8, 2017
1 parent 28920bc commit 3975f69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 13 additions & 1 deletion pgpy/_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,19 @@ class BrainpoolP512R1(object):
key_size = 512


@utils.register_interface(ec.EllipticCurve)
class X25519(object):
name = 'X25519'
key_size = 256


@utils.register_interface(ec.EllipticCurve)
class Ed25519(object):
name = 'ed25519'
key_size = 256


# add these curves to the _CURVE_TYPES list
for curve in [BrainpoolP256R1, BrainpoolP384R1, BrainpoolP512R1]:
for curve in [BrainpoolP256R1, BrainpoolP384R1, BrainpoolP512R1, X25519, Ed25519]:
if curve.name not in ec._CURVE_TYPES and curve.name in _openssl_get_supported_curves():
ec._CURVE_TYPES[curve.name] = curve
6 changes: 3 additions & 3 deletions pgpy/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from .decorators import classproperty
from .types import FlagEnum
from ._curves import BrainpoolP256R1, BrainpoolP384R1, BrainpoolP512R1
from ._curves import BrainpoolP256R1, BrainpoolP384R1, BrainpoolP512R1, X25519, Ed25519

__all__ = ['Backend',
'EllipticCurveOID',
Expand Down Expand Up @@ -58,12 +58,12 @@ class EllipticCurveOID(Enum):
#:
#: .. warning::
#: This curve is not currently usable by PGPy
Curve25519 = ('1.3.6.1.4.1.3029.1.5.1', )
Curve25519 = ('1.3.6.1.4.1.3029.1.5.1', X25519)

This comment has been minimized.

Copy link
@juga0

juga0 Nov 12, 2017

Why is here called Curve25519 and in the rest X25519?

This comment has been minimized.

Copy link
@Commod0re

Commod0re Nov 13, 2017

Author Contributor

Curve25519 is the name of the underlying curve, while X25519 is the DH function that uses that underlying curve (and how it is named in OpenSSL, differentiating it from Ed25519 which is used for signatures). Mostly I've based the naming of things on how they are named in the relevant RFC(s), and failing that, how they are named in GnuPG.

Do you think it would be clearer for users to change the enum member name to X25519?

#: Twisted Edwards variant of Curve25519
#:
#: .. warning::
#: This curve is not currently usable by PGPy
Ed25519 = ('1.3.6.1.4.1.11591.15.1', )
Ed25519 = ('1.3.6.1.4.1.11591.15.1', Ed25519)
#: NIST P-256, also known as SECG curve secp256r1
NIST_P256 = ('1.2.840.10045.3.1.7', ec.SECP256R1)
#: NIST P-384, also known as SECG curve secp384r1
Expand Down

0 comments on commit 3975f69

Please sign in to comment.