Line data Source code
1 : #ifndef HEADER_fd_src_ballet_x509_fd_x509_gen_h 2 : #define HEADER_fd_src_ballet_x509_fd_x509_gen_h 3 : 4 : /* fd_x509_mock.h generates mock X.509 certificates for QUIC 5 : peer-to-peer use. These certificates are deliberately crafted to 6 : pass as valid when connecting to a rustls peer. They are however 7 : semantically invalid (e.g. hardcoded to subject 'localhost'). The 8 : use of X.509 is a mistake in the first place, and should be fixed via 9 : RFC 7250 raw public keys. As soon as raw public keys are implemented 10 : network wide, this code should be deleted. */ 11 : 12 : #include "../../util/fd_util_base.h" 13 : 14 : /* FD_X509_MOCK_CERT_SZ is the byte size of the DER serialization of a 15 : mock X.509 certificate */ 16 : 17 78006750 : #define FD_X509_MOCK_CERT_SZ (0xf9) 18 : 19 : FD_PROTOTYPES_BEGIN 20 : 21 : /* fd_x509_mock_cert generates a dummy X.509 certificate given an 22 : Ed25519 public key. Resulting cert will contain an invalid 23 : signature. Certificate bytes (of size FD_X509_MOCK_CERT_SZ) are 24 : copied out to buf. */ 25 : 26 : void 27 : fd_x509_mock_cert( uchar buf[ static FD_X509_MOCK_CERT_SZ ], 28 : uchar public_key[ static 32 ] ); 29 : 30 : /* fd_x509_mock_pubkey peeks the Ed25519 public key from a dummy X.509 31 : certificate that was previously generated by fd_x509_mock_cert. 32 : Returns NULL if parsing failed. Returns pointer to public key within 33 : 'cert' on success. (Note that the return pointer is unaligned) */ 34 : 35 : uchar const * 36 : fd_x509_mock_pubkey( uchar const * cert, 37 : ulong cert_sz ); 38 : 39 : FD_PROTOTYPES_END 40 : 41 : #endif /* HEADER_fd_src_ballet_x509_fd_x509_gen_h */