MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_ciphers

Method get_ciphers

crates/stdlib/src/openssl.rs:1059–1092  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1057
1058 #[pymethod]
1059 fn get_ciphers(&self, vm: &VirtualMachine) -> PyResult<PyListRef> {
1060 let ctx = self.ctx();
1061 let ssl = ssl::Ssl::new(&ctx).map_err(|e| convert_openssl_error(vm, e))?;
1062
1063 unsafe {
1064 let ciphers_ptr = SSL_get_ciphers(ssl.as_ptr());
1065 if ciphers_ptr.is_null() {
1066 return Ok(vm.ctx.new_list(vec![]));
1067 }
1068
1069 let num_ciphers = sys::OPENSSL_sk_num(ciphers_ptr as *const _);
1070 let mut result = Vec::new();
1071
1072 for i in 0..num_ciphers {
1073 let cipher_ptr =
1074 sys::OPENSSL_sk_value(ciphers_ptr as *const _, i) as *const sys::SSL_CIPHER;
1075 let cipher = ssl::SslCipherRef::from_ptr(cipher_ptr as *mut _);
1076
1077 let (name, version, bits) = cipher_to_tuple(cipher);
1078 let dict = vm.ctx.new_dict();
1079 dict.set_item("name", vm.ctx.new_str(name).into(), vm)?;
1080 dict.set_item("protocol", vm.ctx.new_str(version).into(), vm)?;
1081 dict.set_item("secret_bits", vm.ctx.new_int(bits).into(), vm)?;
1082
1083 // Add description field
1084 let description = cipher_description(cipher_ptr);
1085 dict.set_item("description", vm.ctx.new_str(description).into(), vm)?;
1086
1087 result.push(dict.into());
1088 }
1089
1090 Ok(vm.ctx.new_list(result))
1091 }
1092 }
1093
1094 #[pymethod]
1095 fn set_ecdh_curve(

Callers

nothing calls this directly

Calls 12

newFunction · 0.85
convert_openssl_errorFunction · 0.85
cipher_to_tupleFunction · 0.85
cipher_descriptionFunction · 0.85
new_listMethod · 0.80
new_dictMethod · 0.80
ctxMethod · 0.45
as_ptrMethod · 0.45
set_itemMethod · 0.45
new_strMethod · 0.45
new_intMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected