Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
rfc4490.py114 linesDownload Raw Back to pyasn1_modules
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, LLC7# License: http://snmplabs.com/pyasn1/license.html8#9# Using the GOST 28147-89, GOST R 34.11-94, GOST R 34.10-94, and10#   GOST R 34.10-2001 Algorithms with the CMS11#12# ASN.1 source from:13# https://www.rfc-editor.org/rfc/rfc4490.txt14#15 16 17from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful18 19from pyasn1_modules import rfc435720from pyasn1_modules import rfc528021 22 23# Imports from RFC 435724 25id_CryptoPro_algorithms = rfc4357.id_CryptoPro_algorithms26 27id_GostR3410_94 = rfc4357.id_GostR3410_9428 29id_GostR3410_2001 = rfc4357.id_GostR3410_200130 31Gost28147_89_ParamSet = rfc4357.Gost28147_89_ParamSet32 33Gost28147_89_EncryptedKey = rfc4357.Gost28147_89_EncryptedKey34 35GostR3410_94_PublicKeyParameters = rfc4357.GostR3410_94_PublicKeyParameters36 37GostR3410_2001_PublicKeyParameters = rfc4357.GostR3410_2001_PublicKeyParameters38 39 40# Imports from RFC 528041 42SubjectPublicKeyInfo = rfc5280.SubjectPublicKeyInfo43 44 45# CMS/PKCS#7 key agreement algorithms & parameters46 47class Gost28147_89_KeyWrapParameters(univ.Sequence):48    componentType = namedtype.NamedTypes(49        namedtype.NamedType('encryptionParamSet', Gost28147_89_ParamSet()),50        namedtype.OptionalNamedType('ukm', univ.OctetString().subtype(51            subtypeSpec=constraint.ValueSizeConstraint(8, 8)))52    )53 54 55id_Gost28147_89_CryptoPro_KeyWrap = id_CryptoPro_algorithms + (13, 1, )56 57 58id_Gost28147_89_None_KeyWrap = id_CryptoPro_algorithms + (13, 0, )59 60 61id_GostR3410_2001_CryptoPro_ESDH = id_CryptoPro_algorithms + (96, )62 63 64id_GostR3410_94_CryptoPro_ESDH = id_CryptoPro_algorithms + (97, )65 66 67# CMS/PKCS#7 key transport algorithms & parameters68 69id_GostR3410_2001_KeyTransportSMIMECapability = id_GostR3410_200170 71 72id_GostR3410_94_KeyTransportSMIMECapability = id_GostR3410_9473 74 75class GostR3410_TransportParameters(univ.Sequence):76    componentType = namedtype.NamedTypes(77        namedtype.NamedType('encryptionParamSet', Gost28147_89_ParamSet()),78        namedtype.OptionalNamedType('ephemeralPublicKey', 79            SubjectPublicKeyInfo().subtype(implicitTag=tag.Tag(80                tag.tagClassContext, tag.tagFormatSimple, 0))),81        namedtype.NamedType('ukm', univ.OctetString().subtype(82            subtypeSpec=constraint.ValueSizeConstraint(8, 8)))83    )84 85class GostR3410_KeyTransport(univ.Sequence):86    componentType = namedtype.NamedTypes(87        namedtype.NamedType('sessionEncryptedKey', Gost28147_89_EncryptedKey()),88        namedtype.OptionalNamedType('transportParameters',89            GostR3410_TransportParameters().subtype(implicitTag=tag.Tag(90                tag.tagClassContext, tag.tagFormatConstructed, 0)))91    )92 93 94# GOST R 34.10-94 signature algorithm & parameters95 96class GostR3410_94_Signature(univ.OctetString):97    subtypeSpec = constraint.ValueSizeConstraint(64, 64)98 99 100# GOST R 34.10-2001 signature algorithms and parameters101 102class GostR3410_2001_Signature(univ.OctetString):103    subtypeSpec = constraint.ValueSizeConstraint(64, 64)104 105 106# Update the Algorithm Identifier map in rfc5280.py107 108_algorithmIdentifierMapUpdate = {109    id_Gost28147_89_CryptoPro_KeyWrap: Gost28147_89_KeyWrapParameters(),110    id_Gost28147_89_None_KeyWrap: Gost28147_89_KeyWrapParameters(),111}112 113rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)114 
codekingpro/portable-devtools · Team Ai