| 1 |
# SPDX-License-Identifier: MPL-2.0 |
| 2 |
|
| 3 |
import attr |
| 4 |
|
| 5 |
import cryptodatahub.common.algorithm |
| 6 |
import cryptodatahub.common.pqc |
| 7 |
import cryptodatahub.tls.algorithm |
| 8 |
|
| 9 |
|
| 10 |
@attr.s(frozen=True) |
| 11 |
class FetchedKeyEncapsulationMechanismParams( |
| 12 |
cryptodatahub.common.pqc.KeyEncapsulationMechanismParams |
| 13 |
): |
| 14 |
identifier = attr.ib(kw_only=True, validator=attr.validators.instance_of(str)) |
| 15 |
|
| 16 |
def _asdict(self): |
| 17 |
as_dict = super()._asdict() |
| 18 |
as_dict.pop('identifier', None) |
| 19 |
|
| 20 |
return as_dict |
| 21 |
|
| 22 |
|
| 23 |
@attr.s(frozen=True) |
| 24 |
class FetchedHybridNamedGroupParams(cryptodatahub.common.pqc.HybridNamedGroupParams): |
| 25 |
identifier = attr.ib(kw_only=True, validator=attr.validators.instance_of(str)) |
| 26 |
|
| 27 |
def _asdict(self): |
| 28 |
as_dict = super()._asdict() |
| 29 |
as_dict.pop('identifier', None) |
| 30 |
|
| 31 |
return as_dict |
| 32 |
|
| 33 |
|
| 34 |
@attr.s(frozen=True) |
| 35 |
class FetchedNamedCurveParams(cryptodatahub.tls.algorithm.NamedCurveParams): |
| 36 |
identifier = attr.ib(kw_only=True, validator=attr.validators.instance_of(str)) |
| 37 |
|
| 38 |
def _asdict(self): |
| 39 |
as_dict = super()._asdict() |
| 40 |
|
| 41 |
as_dict.pop('identifier', None) |
| 42 |
as_dict.pop('gradeables', None) |
| 43 |
|
| 44 |
as_dict['_code_in_hex'] = f'0x{self.code:04x}' |
| 45 |
as_dict.move_to_end('_code_in_hex', last=False) |
| 46 |
|
| 47 |
return as_dict |
| 48 |
|
| 49 |
|
| 50 |
@attr.s(frozen=True) |
| 51 |
class FetchedAuthenticationParams(cryptodatahub.common.algorithm.AuthenticationParams): |
| 52 |
identifier = attr.ib(kw_only=True, validator=attr.validators.instance_of(str)) |
| 53 |
|
| 54 |
def _asdict(self): |
| 55 |
as_dict = super()._asdict() |
| 56 |
as_dict.pop('identifier', None) |
| 57 |
|
| 58 |
return as_dict |
| 59 |
|
| 60 |
|
| 61 |
@attr.s(frozen=True) |
| 62 |
class FetchedHashAndSignatureAlgorithmParams(cryptodatahub.tls.algorithm.HashAndSignatureAlgorithmParams): |
| 63 |
identifier = attr.ib(kw_only=True, validator=attr.validators.instance_of(str)) |
| 64 |
|
| 65 |
def _asdict(self): |
| 66 |
as_dict = super()._asdict() |
| 67 |
|
| 68 |
as_dict.pop('identifier', None) |
| 69 |
as_dict.pop('gradeables', None) |
| 70 |
as_dict.pop('last_version', None) |
| 71 |
|
| 72 |
as_dict['_code_in_hex'] = f'0x{self.code:04x}' |
| 73 |
as_dict.move_to_end('_code_in_hex', last=False) |
| 74 |
|
| 75 |
return as_dict |