1#
2# This file is part of pyasn1-modules software.
3#
4# Created by Russ Housley with assistance from asn1ate v.0.6.0.
5#
6# Copyright (c) 2019, Vigil Security, LLC
7# License: http://snmplabs.com/pyasn1/license.html
8#
9#The scrypt Password-Based Key Derivation Function
10#
11# ASN.1 source from:
12# https://www.rfc-editor.org/rfc/rfc8520.txt
13# https://www.rfc-editor.org/errata/eid5871
14#
15
16from pyasn1.type import constraint
17from pyasn1.type import namedtype
18from pyasn1.type import univ
19
20from pyasn1_modules import rfc5280
21
22MAX = float('inf')
23
24
25id_scrypt = univ.ObjectIdentifier('1.3.6.1.4.1.11591.4.11')
26
27
28class Scrypt_params(univ.Sequence):
29    componentType = namedtype.NamedTypes(
30        namedtype.NamedType('salt',
31            univ.OctetString()),
32        namedtype.NamedType('costParameter',
33            univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, MAX))),
34        namedtype.NamedType('blockSize',
35            univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, MAX))),
36        namedtype.NamedType('parallelizationParameter',
37            univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, MAX))),
38        namedtype.OptionalNamedType('keyLength',
39            univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, MAX)))
40    )
41
42
43# Update the Algorithm Identifier map in rfc5280.py
44
45_algorithmIdentifierMapUpdate = {
46    id_scrypt: Scrypt_params(),
47}
48
49rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)
50