Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: third_party/google-endpoints/jwkest/curves.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # =======================
2 # From the pyECC package
3 # =======================
4 #
5 # Predefined Elliptic Curves
6 # for use in signing and key exchange
7 #
8 """
9 Predefined elliptic curves for use in signing and key exchange.
10 This Module implements FIPS approved standard curves P-192, P-224, P-256,
11 P-384 and P-521 along with two weak non-standard curves of field size 128
12 and 160 bits.
13
14 The weak curves cannot be used for signing but provide a faster way to
15 obfuscate non-critical transmissions.
16 """
17
18 # FIPS approved elliptic curves over prime fields
19 # (see FIPS 186-3, Appendix D.1.2)
20 DOMAINS = {
21 # Bits : (p, order of E(GF(P)), parameter b, base point x, base point y)
22 192: (0xfffffffffffffffffffffffffffffffeffffffffffffffff,
23 0xffffffffffffffffffffffff99def836146bc9b1b4d22831,
24 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1,
25 0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012,
26 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811),
27
28 224: (0xffffffffffffffffffffffffffffffff000000000000000000000001,
29 0xffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d,
30 0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4,
31 0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21,
32 0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34),
33
34 256: (0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff,
35 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551,
36 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b,
37 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296,
38 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5),
39
40 384: (
41 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff00 00000000000000ffffffff,
42 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248 b0a77aecec196accc52973,
43 0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a 2ed19d2a85c8edd3ec2aef,
44 0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf 55296c3a545e3872760ab7,
45 0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d 7e819d7a431d7c90ea0e5f),
46
47 521: (
48 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff fffffffffffffffffffffffffffffffffffffffffffffffffffffffff,
49 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa5186878 3bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409,
50 0x051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e15619395 1ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00,
51 0x0c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e7 7efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66,
52 0x11839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee729 95ef42640c550b9013fad0761353c7086a272c24088be94769fd16650)
53 }
54
55
56 # Additional non-standard curves for low security but high performance
57 # (not intended for use in signing, hence the missing group order)
58
59 DOMAINS.update({
60 128: (0xffffffffffffffffffffffffffffff61,
61 None,
62 0xd83d3eb8266a89927d73d5fe263d5f23,
63 0xa94d2d8531f7af8bde367def12b98ead,
64 0x9f44e1d671beb68fd2df7f877ab13fa6),
65
66 160: (0xffffffffffffffffffffffffffffffffffffffd1,
67 None,
68 0x94bfe70deef7b94742c089ca4db3ca27fbe1f754,
69 0xcc6562c2969ac57524b8d0f300d1f598c908c121,
70 0x952ddde80a252683dd7ba90fb5919899b5af69f5)
71 })
72
73 CURVE_P = 3 # global parameter of all curves (for efficiency reasons)
74
75
76 def get_curve(bits):
77 """Get a known curve of the given size => (bits, prime, order, p, q, point).
78 Order may be None if unknown."""
79 if bits in DOMAINS:
80 p, n, b, x, y = DOMAINS[bits]
81 return bits, p, n, CURVE_P, p - b, (x, y)
82 else:
83 raise KeyError("Key size not implemented: %s" % bits)
84
85
86 def implemented_keys(must_sign=False):
87 return [k for k in DOMAINS if not must_sign or DOMAINS[k][1]]
OLDNEW
« no previous file with comments | « third_party/google-endpoints/jwkest/aes_key_wrap.py ('k') | third_party/google-endpoints/jwkest/ecc.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698