MCPcopy Create free account
hub / github.com/secdev/scapy / setSubjectPublicKeyFromPrivateKey

Method setSubjectPublicKeyFromPrivateKey

scapy/layers/tls/cert.py:1038–1052  ·  view source on GitHub ↗

Replace the subjectPublicKeyInfo of this certificate with the one from the provided key.

(self, key)

Source from the content-addressed store, hash-verified

1036 return _get_hash(_get_cert_sig_hashname(self))
1037
1038 def setSubjectPublicKeyFromPrivateKey(self, key):
1039 """
1040 Replace the subjectPublicKeyInfo of this certificate with the one from
1041 the provided key.
1042 """
1043 if isinstance(key, (PubKey, PrivKey)):
1044 if isinstance(key, PrivKey):
1045 pubkey = key.pubkey
1046 else:
1047 pubkey = key
1048 self.tbsCertificate.subjectPublicKeyInfo = X509_SubjectPublicKeyInfo(
1049 pubkey.der
1050 )
1051 else:
1052 raise ValueError("Unknown type 'key', should be PubKey or PrivKey")
1053
1054 def resignWith(self, key):
1055 """

Callers 1

gen_alike_chainMethod · 0.95

Calls 1

Tested by

no test coverage detected