For a normal and High level use, specifie pubkey, privkey (if you need) and the curve
(self, pubkey=None, privkey=None, pubkey_x=None,
pubkey_y=None, raw_privkey=None, curve='sect283r1')
| 41 | |
| 42 | """ |
| 43 | def __init__(self, pubkey=None, privkey=None, pubkey_x=None, |
| 44 | pubkey_y=None, raw_privkey=None, curve='sect283r1'): |
| 45 | """ |
| 46 | For a normal and High level use, specifie pubkey, |
| 47 | privkey (if you need) and the curve |
| 48 | """ |
| 49 | if type(curve) == str: |
| 50 | self.curve = OpenSSL.get_curve(curve) |
| 51 | else: |
| 52 | self.curve = curve |
| 53 | |
| 54 | if pubkey_x is not None and pubkey_y is not None: |
| 55 | self._set_keys(pubkey_x, pubkey_y, raw_privkey) |
| 56 | elif pubkey is not None: |
| 57 | curve, pubkey_x, pubkey_y, i = ECC._decode_pubkey(pubkey) |
| 58 | if privkey is not None: |
| 59 | curve2, raw_privkey, i = ECC._decode_privkey(privkey) |
| 60 | if curve != curve2: |
| 61 | raise Exception("Bad ECC keys ...") |
| 62 | self.curve = curve |
| 63 | self._set_keys(pubkey_x, pubkey_y, raw_privkey) |
| 64 | else: |
| 65 | self.privkey, self.pubkey_x, self.pubkey_y = self._generate() |
| 66 | |
| 67 | def _set_keys(self, pubkey_x, pubkey_y, privkey): |
| 68 | if self.raw_check_key(privkey, pubkey_x, pubkey_y) < 0: |
nothing calls this directly
no test coverage detected