(&self, vm: &VirtualMachine)
| 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( |
nothing calls this directly
no test coverage detected