Note that this will always copy the signature field from the tbsCertificate into the signatureAlgorithm field of the result, regardless of the coherence between its contents (which might indicate ecdsa-with-SHA512) and the result (e.g. RSA signing MD2). Ther
(self, tbsCert, h="sha256")
| 644 | """ |
| 645 | |
| 646 | def signTBSCert(self, tbsCert, h="sha256"): |
| 647 | """ |
| 648 | Note that this will always copy the signature field from the |
| 649 | tbsCertificate into the signatureAlgorithm field of the result, |
| 650 | regardless of the coherence between its contents (which might |
| 651 | indicate ecdsa-with-SHA512) and the result (e.g. RSA signing MD2). |
| 652 | |
| 653 | There is a small inheritance trick for the computation of sigVal |
| 654 | below: in order to use a sign() method which would apply |
| 655 | to both PrivKeyRSA and PrivKeyECDSA, the sign() methods of the |
| 656 | subclasses accept any argument, be it from the RSA or ECDSA world, |
| 657 | and then they keep the ones they're interested in. |
| 658 | Here, t will be passed eventually to pkcs1._DecryptAndSignRSA.sign(). |
| 659 | """ |
| 660 | sigAlg = tbsCert.signature |
| 661 | h = h or hash_by_oid[sigAlg.algorithm.val] |
| 662 | sigVal = self.sign(bytes(tbsCert), h=h, t="pkcs") |
| 663 | c = X509_Cert() |
| 664 | c.tbsCertificate = tbsCert |
| 665 | c.signatureAlgorithm = sigAlg |
| 666 | c.signatureValue = _Raw_ASN1_BIT_STRING(sigVal, readable=True) |
| 667 | return c |
| 668 | |
| 669 | def resignCert(self, cert): |
| 670 | """Rewrite the signature of either a Cert or an X509_Cert.""" |
no test coverage detected