您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

53 行
1.7 KiB

  1. # Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu>
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # https://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """ASN.1 definitions.
  15. Not all ASN.1-handling code use these definitions, but when it does, they should be here.
  16. """
  17. from pyasn1.type import univ, namedtype, tag
  18. class PubKeyHeader(univ.Sequence):
  19. componentType = namedtype.NamedTypes(
  20. namedtype.NamedType("oid", univ.ObjectIdentifier()),
  21. namedtype.NamedType("parameters", univ.Null()),
  22. )
  23. class OpenSSLPubKey(univ.Sequence):
  24. componentType = namedtype.NamedTypes(
  25. namedtype.NamedType("header", PubKeyHeader()),
  26. # This little hack (the implicit tag) allows us to get a Bit String as Octet String
  27. namedtype.NamedType(
  28. "key",
  29. univ.OctetString().subtype(implicitTag=tag.Tag(tagClass=0, tagFormat=0, tagId=3)),
  30. ),
  31. )
  32. class AsnPubKey(univ.Sequence):
  33. """ASN.1 contents of DER encoded public key:
  34. RSAPublicKey ::= SEQUENCE {
  35. modulus INTEGER, -- n
  36. publicExponent INTEGER, -- e
  37. """
  38. componentType = namedtype.NamedTypes(
  39. namedtype.NamedType("modulus", univ.Integer()),
  40. namedtype.NamedType("publicExponent", univ.Integer()),
  41. )