@@ -388,6 +388,19 @@ DSA keys look almost identical but begin with ``ssh-dss`` rather than
388
388
``ssh-rsa ``. ECDSA keys have a slightly different format, they begin with
389
389
``ecdsa-sha2-{curve} ``.
390
390
391
+
392
+ .. data :: SSHPublicKeyTypes
393
+
394
+ .. versionadded :: 40.0.0
395
+
396
+ Type alias: A union of public key types accepted for SSH:
397
+ :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey `,
398
+ :class: `~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey `,
399
+ :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey `
400
+ , or
401
+ :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PublicKey `.
402
+
403
+
391
404
.. function :: load_ssh_public_key(data)
392
405
393
406
.. versionadded :: 0.7
@@ -404,13 +417,8 @@ DSA keys look almost identical but begin with ``ssh-dss`` rather than
404
417
:param data: The OpenSSH encoded key data.
405
418
:type data: :term: `bytes-like `
406
419
407
- :returns: One of
408
- :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey `,
409
- :class: `~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey `,
410
- :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey `
411
- , or
412
- :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PublicKey `,
413
- depending on the contents of ``data ``.
420
+ :returns: One of :data: `SSHPublicKeyTypes ` depending on the contents of
421
+ ``data ``.
414
422
415
423
:raises ValueError: If the OpenSSH data could not be properly decoded or
416
424
if the key is not in the proper format.
@@ -436,6 +444,18 @@ An example ECDSA key in OpenSSH format::
436
444
BAUGBw==
437
445
-----END OPENSSH PRIVATE KEY-----
438
446
447
+ .. data :: SSHPrivateKeyTypes
448
+
449
+ .. versionadded :: 40.0.0
450
+
451
+ Type alias: A union of private key types accepted for SSH:
452
+ :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey `,
453
+ :class: `~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey `,
454
+ :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey `
455
+ or
456
+ :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey `.
457
+
458
+
439
459
.. function :: load_ssh_private_key(data, password)
440
460
441
461
.. versionadded :: 3.0
@@ -454,13 +474,8 @@ An example ECDSA key in OpenSSH format::
454
474
:param bytes password: Password bytes to use to decrypt
455
475
password-protected key. Or ``None `` if not needed.
456
476
457
- :returns: One of
458
- :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey `,
459
- :class: `~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey `,
460
- :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey `
461
- or
462
- :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey `,
463
- depending on the contents of ``data ``.
477
+ :returns: One of :data: `SSHPrivateKeyTypes ` depending on the contents of
478
+ ``data ``.
464
479
465
480
:raises ValueError: If the OpenSSH data could not be properly decoded,
466
481
if the key is not in the proper format or the incorrect password
@@ -476,6 +491,28 @@ OpenSSH Certificate
476
491
The format used by OpenSSH for certificates, as specified in
477
492
`PROTOCOL.certkeys `_.
478
493
494
+ .. data :: SSHCertPublicKeyTypes
495
+
496
+ .. versionadded :: 40.0.0
497
+
498
+ Type alias: A union of public key types supported for SSH
499
+ certificates:
500
+ :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey `,
501
+ :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey `
502
+ or
503
+ :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PublicKey `
504
+
505
+ .. data :: SSHCertPrivateKeyTypes
506
+
507
+ .. versionadded :: 40.0.0
508
+
509
+ Type alias: A union of private key types supported for SSH
510
+ certificates:
511
+ :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey `,
512
+ :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey `
513
+ or
514
+ :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey `
515
+
479
516
.. function :: load_ssh_public_identity(data)
480
517
481
518
.. versionadded :: 40.0.0
@@ -494,12 +531,7 @@ The format used by OpenSSH for certificates, as specified in
494
531
:param data: The OpenSSH encoded data.
495
532
:type data: bytes
496
533
497
- :returns: :class: `SSHCertificate ` or one of
498
- :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey `,
499
- :class: `~cryptography.hazmat.primitives.asymmetric.dsa.DSAPublicKey `,
500
- :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey `
501
- , or
502
- :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PublicKey `.
534
+ :returns: :class: `SSHCertificate ` or one of :data: `SSHCertPublicKeyTypes `.
503
535
504
536
:raises ValueError: If the OpenSSH data could not be properly decoded.
505
537
@@ -521,12 +553,8 @@ The format used by OpenSSH for certificates, as specified in
521
553
522
554
.. method :: public_key()
523
555
524
- :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey `,
525
- :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey `
526
- or
527
- :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PublicKey `
528
-
529
- The public key contained in the certificate.
556
+ The public key contained in the certificate, one of
557
+ :data: `SSHCertPublicKeyTypes `.
530
558
531
559
.. attribute :: serial
532
560
@@ -597,12 +625,8 @@ The format used by OpenSSH for certificates, as specified in
597
625
598
626
.. method :: signature_key()
599
627
600
- :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey `,
601
- :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey `
602
- or
603
- :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PublicKey `
604
-
605
- The public key used to sign the certificate.
628
+ The public key used to sign the certificate, one of
629
+ :data: `SSHCertPublicKeyTypes `.
606
630
607
631
.. method :: verify_cert_signature()
608
632
@@ -689,10 +713,7 @@ SSH Certificate Builder
689
713
690
714
:param public_key: The public key to be included in the certificate.
691
715
This value is required.
692
- :type public_key: :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey `,
693
- :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey `
694
- or
695
- :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PublicKey `
716
+ :type public_key: :data: `SSHCertPublicKeyTypes `
696
717
697
718
.. method :: serial(serial)
698
719
@@ -755,10 +776,7 @@ SSH Certificate Builder
755
776
756
777
:param private_key: The private key that will be used to sign the
757
778
certificate.
758
- :type private_key: :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey `,
759
- :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey `
760
- or
761
- :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey `
779
+ :type private_key: :data: `SSHCertPrivateKeyTypes `
762
780
763
781
:return: The signed certificate.
764
782
:rtype: :class: `SSHCertificate `
@@ -777,6 +795,23 @@ file suffix.
777
795
``cryptography `` only supports a single private key and associated
778
796
certificates when parsing PKCS12 files at this time.
779
797
798
+
799
+ .. data :: PKCS12PrivateKeyTypes
800
+
801
+ .. versionadded :: 40.0.0
802
+
803
+ Type alias: A union of private key types supported for PKCS12
804
+ serialization:
805
+ :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey `
806
+ ,
807
+ :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey `
808
+ ,
809
+ :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey `
810
+ ,
811
+ :class: `~cryptography.hazmat.primitives.asymmetric.ed448.Ed448PrivateKey `
812
+ or
813
+ :class: `~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey `.
814
+
780
815
.. function :: load_key_and_certificates(data, password)
781
816
782
817
.. versionadded :: 2.5
@@ -847,17 +882,7 @@ file suffix.
847
882
:type name: bytes
848
883
849
884
:param key: The private key to include in the structure.
850
- :type key: An
851
- :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey `
852
- ,
853
- :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey `
854
- ,
855
- :class: `~cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey `
856
- ,
857
- :class: `~cryptography.hazmat.primitives.asymmetric.ed448.Ed448PrivateKey `
858
- , or
859
- :class: `~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey `
860
- object.
885
+ :type key: :data: `PKCS12PrivateKeyTypes `
861
886
862
887
:param cert: The certificate associated with the private key.
863
888
:type cert: :class: `~cryptography.x509.Certificate ` or ``None ``
@@ -933,7 +958,8 @@ file suffix.
933
958
.. attribute :: key
934
959
935
960
An optional private key belonging to
936
- :attr: `~cryptography.hazmat.primitives.serialization.pkcs12.PKCS12KeyAndCertificates.cert `.
961
+ :attr: `~cryptography.hazmat.primitives.serialization.pkcs12.PKCS12KeyAndCertificates.cert `
962
+ (see :data: `PKCS12PrivateKeyTypes `).
937
963
938
964
.. attribute :: cert
939
965
@@ -980,6 +1006,25 @@ contain certificates, CRLs, and much more. PKCS7 files commonly have a ``p7b``,
980
1006
``cryptography `` only supports parsing certificates from PKCS7 files at
981
1007
this time.
982
1008
1009
+ .. data :: PKCS7HashTypes
1010
+
1011
+ .. versionadded :: 40.0.0
1012
+
1013
+ Type alias: A union of hash types supported for PKCS7 serialization:
1014
+ :class: `~cryptography.hazmat.primitives.hashes.SHA1 `,
1015
+ :class: `~cryptography.hazmat.primitives.hashes.SHA224 `,
1016
+ :class: `~cryptography.hazmat.primitives.hashes.SHA256 `,
1017
+ :class: `~cryptography.hazmat.primitives.hashes.SHA384 `, or
1018
+ :class: `~cryptography.hazmat.primitives.hashes.SHA512 `.
1019
+
1020
+ .. data :: PKCS7PrivateKeyTypes
1021
+
1022
+ .. versionadded :: 40.0.0
1023
+
1024
+ Type alias: A union of private key types supported for PKCS7 serialization:
1025
+ :class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey ` or
1026
+ :class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey `
1027
+
983
1028
.. function :: load_pem_pkcs7_certificates(data)
984
1029
985
1030
.. versionadded :: 3.1
@@ -1089,16 +1134,13 @@ contain certificates, CRLs, and much more. PKCS7 files commonly have a ``p7b``,
1089
1134
:param private_key: The
1090
1135
:class: `~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey ` or
1091
1136
:class: `~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey `
1092
- associated with the certificate provided.
1137
+ associated with the certificate provided
1138
+ (matches :data: `PKCS7PrivateKeyTypes `).
1093
1139
1094
1140
:param hash_algorithm: The
1095
1141
:class: `~cryptography.hazmat.primitives.hashes.HashAlgorithm ` that
1096
- will be used to generate the signature. This must be an instance of
1097
- :class: `~cryptography.hazmat.primitives.hashes.SHA1 `,
1098
- :class: `~cryptography.hazmat.primitives.hashes.SHA224 `,
1099
- :class: `~cryptography.hazmat.primitives.hashes.SHA256 `,
1100
- :class: `~cryptography.hazmat.primitives.hashes.SHA384 `, or
1101
- :class: `~cryptography.hazmat.primitives.hashes.SHA512 `.
1142
+ will be used to generate the signature. This must be one of the
1143
+ types in :data: `PKCS7HashTypes `.
1102
1144
1103
1145
.. method :: add_certificate(certificate)
1104
1146
0 commit comments