ring
ring copied to clipboard
Change statics to const, where possible
In rustls-ffi, we are hoping to export some ciphersuites (rustls::SupportedCipherSuite
structs) to C code, by putting them in a const array (see https://github.com/rustls/rustls-ffi/pull/165). One obstacle we are running into is that each rustls::SupportedCipherSuite
has several statics inside of it, and you can't declare a const that points to statics:
pub static TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite =
SupportedCipherSuite::Tls12(&Tls12CipherSuite {
common: CipherSuiteCommon {
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
bulk: BulkAlgorithm::Chacha20Poly1305,
aead_algorithm: &ring::aead::CHACHA20_POLY1305,
},
kx: KeyExchangeAlgorithm::ECDHE,
sign: TLS12_ECDSA_SCHEMES,
fixed_iv_len: 12,
explicit_nonce_len: 0,
aead_alg: &ChaCha20Poly1305,
hmac_algorithm: ring::hmac::HMAC_SHA256,
});
I am not a Rust expert, but from my understanding, the Rust compiler has gotten smarter about its ability to evaluate consts, which may make the conversion from static to const possible now, especially if your compatibility guarantee is only for the latest stable version of Rust.
If there is otherwise no difference, would it be possible to change some of the static
values in ring to const
values instead?
I will take a shot at a patch to see if it's technically feasible, then we can go from there.