On 12 January 2017 at 18:49, Cory Benfield <c...@lukasa.co.uk> wrote:
>
>> On 12 Jan 2017, at 05:36, Wes Turner <wes.tur...@gmail.com> wrote:
>>
>> So, with
>>
>> ```
>> class TLSVersion(Enum):
>>         MINIMUM_SUPPORTED
>>         SSLv2
>>         SSLv3
>>         TLSv1
>>         TLSv1_1
>>         TLSv1_2
>>         TLSv1_3
>>         MAXIMUM_SUPPORTED
>> ```
>>
>> What are the (signed?) integer values?
>
> Sorry Wes, I missed this in my first reply.
>
> Does it matter? The concrete implementations should be looking for the enum 
> entries directly. The actual values shouldn’t matter, especially as different 
> TLS APIs have very different methods of actually configuring this.

For "Enums" where I genuinely don't care about the values, I'll
typically set them to the string that matches the attribute name:

```
class TLSVersion(Enum):
        SSLv2 = "SSLv2"
        MINIMUM_SUPPORTED = SSLv2
        SSLv3 = "SSLv3"
        TLSv1= "TLSv1"
        TLSv1_1 = "TLSv1_1"
        TLSv1_2 = "TLSv1_2"
        TLSv1_3 = "TLSv1_3"
        MAXIMUM_SUPPORTED = TLSv1_3
```

That way folks get sensible answers regardless of whether they
reference the enum entry name or its value, or render it directly with
repr() or str():

    >>> TLSVersion.MINIMUM_SUPPORTED
    <TLSVersion.SSLv2: 'SSLv2'>
    >>> TLSVersion.MAXIMUM_SUPPORTED
    <TLSVersion.TLSv1_3: 'TLSv1_3'>
    >>> str(TLSVersion.MAXIMUM_SUPPORTED)
    'TLSVersion.TLSv1_3'
    >>> TLSVersion.MAXIMUM_SUPPORTED.name
    'TLSv1_3'
    >>> TLSVersion.MAXIMUM_SUPPORTED.value
    'TLSv1_3'

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Security-SIG mailing list
Security-SIG@python.org
https://mail.python.org/mailman/listinfo/security-sig

Reply via email to