Debian Codegraph @

src/connection/auth.rs

raw symbols SCIP
1 use bytesrust-analyzer cargo bytes 1.12.1 crate/::bufrust-analyzer cargo bytes 1.12.1 buf/::Chainrust-analyzer cargo bytes 1.12.1 buf/chain/Chain#;
2 use bytesrust-analyzer cargo bytes 1.12.1 crate/::Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#;
3 use digestrust-analyzer cargo digest 0.10.7 crate/::{Digestrust-analyzer cargo digest 0.10.7 digest/Digest#, OutputSizeUserrust-analyzer cargo crypto-common 0.1.7 OutputSizeUser#};
4 use generic_arrayrust-analyzer cargo generic-array 0.14.7 crate/::GenericArrayrust-analyzer cargo generic-array 0.14.7 GenericArray#;
5 use randrust-analyzer cargo rand 0.8.7 crate/::thread_rngrust-analyzer cargo rand 0.8.7 rngs/thread/thread_rng().;
6 use rsarust-analyzer cargo rsa 0.9.10 crate/::{pkcs8rust-analyzer cargo pkcs8 0.10.2 crate/::DecodePublicKeyrust-analyzer cargo spki 0.7.3 traits/DecodePublicKey#, Oaeprust-analyzer cargo rsa 0.9.10 oaep/Oaep#, RsaPublicKeyrust-analyzer cargo rsa 0.9.10 key/RsaPublicKey#};
7 use sha1rust-analyzer cargo sha1 0.10.7 crate/::Sha1rust-analyzer cargo sha1 0.10.7 Sha1#;
8 use sha2rust-analyzer cargo sha2 0.10.9 crate/::Sha256rust-analyzer cargo sha2 0.10.9 Sha256#;
9
10 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::connectionrust-analyzer cargo sqlx-mysql 0.8.3 connection/::streamrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/::MySqlStreamrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#;
11 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::errorrust-analyzer cargo sqlx-mysql 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
12 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::protocolrust-analyzer cargo sqlx-mysql 0.8.3 protocol/::authrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/::AuthPluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#;
13 use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::protocolrust-analyzer cargo sqlx-mysql 0.8.3 protocol/::Packetrust-analyzer cargo sqlx-mysql 0.8.3 protocol/packet/Packet#;
14
15 impl AuthPluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin# {
16 pub(superrust-analyzer cargo sqlx-mysql 0.8.3 connection/) async fn scramblerust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/impl#[AuthPlugin]scramble().(
17 self,
18 stream: &mut MySqlStreamrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#,
19 password: &str,
20 nonce: &Chainrust-analyzer cargo bytes 1.12.1 buf/chain/Chain#<Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#>,
21 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
22 match self {
23 // https://mariadb.com/kb/en/caching_sha2_password-authentication-plugin/
24 AuthPluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#::CachingSha2Passwordrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#CachingSha2Password# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(scramble_sha256rust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/scramble_sha256().(password, nonce).to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().()),
25
26 AuthPluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#::MySqlNativePasswordrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#MySqlNativePassword# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(scramble_sha1rust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/scramble_sha1().(password, nonce).to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().()),
27
28 // https://mariadb.com/kb/en/sha256_password-plugin/
29 AuthPluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#::Sha256Passwordrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#Sha256Password# => encrypt_rsarust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/encrypt_rsa().(stream, 0x01, password, nonce).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().,
30
31 AuthPluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#::MySqlClearPasswordrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#MySqlClearPassword# => {
32 let mut pw_bytes = password.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`][ToOwned]to_owned().();
33 pw_bytes.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(0); // null terminate
34 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(pw_bytes)
35 }
36 }
37 }
38
39 pub(superrust-analyzer cargo sqlx-mysql 0.8.3 connection/) async fn handlerust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/impl#[AuthPlugin]handle().(
40 self,
41 stream: &mut MySqlStreamrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#,
42 packet: Packetrust-analyzer cargo sqlx-mysql 0.8.3 protocol/packet/Packet#<Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#>,
43 password: &str,
44 nonce: &Chainrust-analyzer cargo bytes 1.12.1 buf/chain/Chain#<Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#>,
45 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
46 match self {
47 AuthPluginrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#::CachingSha2Passwordrust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/AuthPlugin#CachingSha2Password# if packet[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().0x01 => {
48 match packet[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
49 // AUTH_OK
50 0x03 => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true),
51
52 // AUTH_CONTINUE
53 0x04 => {
54 let payload = encrypt_rsarust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/encrypt_rsa().(stream, 0x02, password, nonce).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
55
56 stream.write_packetrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/impl#[`MySqlStream<S>`]write_packet().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Deref]deref().payload)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
57 stream.flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]flush().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
58
59 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false)
60 }
61
62 v => {
63 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!("unexpected result from fast authentication 0x{:x} when expecting 0x03 (AUTH_OK) or 0x04 (AUTH_CONTINUE)", v))
64 }
65 }
66 }
67
68 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!(
69 "unexpected packet 0x{:02x} for auth plugin '{}' during authentication",
70 packet[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
71 self.namerust-analyzer cargo sqlx-mysql 0.8.3 protocol/auth/impl#[AuthPlugin]name().()
72 )),
73 }
74 }
75 }
76
77 fn scramble_sha1rust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/scramble_sha1().(
78 password: &str,
79 nonce: &Chainrust-analyzer cargo bytes 1.12.1 buf/chain/Chain#<Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#>,
80 ) -> GenericArrayrust-analyzer cargo generic-array 0.14.7 GenericArray#<u8, <Sha1rust-analyzer cargo sha1 0.10.7 Sha1# as OutputSizeUserrust-analyzer cargo crypto-common 0.1.7 OutputSizeUser#>::OutputSizerust-analyzer cargo crypto-common 0.1.7 OutputSizeUser#OutputSize#> {
81 // SHA1( password ) ^ SHA1( seed + SHA1( SHA1( password ) ) )
82 // https://mariadb.com/kb/en/connection/#mysql_native_password-plugin
83
84 let mut ctx = Sha1rust-analyzer cargo sha1 0.10.7 Sha1#::newrust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]new().();
85
86 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(password);
87
88 let mut pw_hash = ctx.finalize_resetrust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]finalize_reset().();
89
90 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(pw_hash);
91
92 let pw_hash_hash = ctx.finalize_resetrust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]finalize_reset().();
93
94 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(nonce.first_refrust-analyzer cargo bytes 1.12.1 buf/chain/impl#[`Chain<T, U>`]first_ref().());
95 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(nonce.last_refrust-analyzer cargo bytes 1.12.1 buf/chain/impl#[`Chain<T, U>`]last_ref().());
96 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(pw_hash_hash);
97
98 let pw_seed_hash_hash = ctx.finalizerust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]finalize().();
99
100 xor_eqrust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/xor_eq().(&mut pw_hash, &pw_seed_hash_hash);
101
102 pw_hash
103 }
104
105 fn scramble_sha256rust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/scramble_sha256().(
106 password: &str,
107 nonce: &Chainrust-analyzer cargo bytes 1.12.1 buf/chain/Chain#<Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#>,
108 ) -> GenericArrayrust-analyzer cargo generic-array 0.14.7 GenericArray#<u8, <Sha256rust-analyzer cargo sha2 0.10.9 Sha256# as OutputSizeUserrust-analyzer cargo crypto-common 0.1.7 OutputSizeUser#>::OutputSizerust-analyzer cargo crypto-common 0.1.7 OutputSizeUser#OutputSize#> {
109 // XOR(SHA256(password), SHA256(seed, SHA256(SHA256(password))))
110 // https://mariadb.com/kb/en/caching_sha2_password-authentication-plugin/#sha-2-encrypted-password
111 let mut ctx = Sha256rust-analyzer cargo sha2 0.10.9 Sha256#::newrust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]new().();
112
113 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(password);
114
115 let mut pw_hash = ctx.finalize_resetrust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]finalize_reset().();
116
117 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(pw_hash);
118
119 let pw_hash_hash = ctx.finalize_resetrust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]finalize_reset().();
120
121 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(nonce.first_refrust-analyzer cargo bytes 1.12.1 buf/chain/impl#[`Chain<T, U>`]first_ref().());
122 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(nonce.last_refrust-analyzer cargo bytes 1.12.1 buf/chain/impl#[`Chain<T, U>`]last_ref().());
123 ctx.updaterust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]update().(pw_hash_hash);
124
125 let pw_seed_hash_hash = ctx.finalizerust-analyzer cargo digest 0.10.7 digest/impl#[D][Digest]finalize().();
126
127 xor_eqrust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/xor_eq().(&mut pw_hash, &pw_seed_hash_hash);
128
129 pw_hash
130 }
131
132 async fn encrypt_rsarust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/encrypt_rsa().<'s>(
133 stream: &'s mut MySqlStreamrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#,
134 public_key_request_id: u8,
135 password: &'s str,
136 nonce: &'s Chainrust-analyzer cargo bytes 1.12.1 buf/chain/Chain#<Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#>,
137 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
138 // https://mariadb.com/kb/en/caching_sha2_password-authentication-plugin/
139
140 if stream.is_tlsrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/MySqlStream#is_tls. {
141 // If in a TLS stream, send the password directly in clear text
142 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(to_ascizrust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/to_asciz().(password));
143 }
144
145 // client sends a public key request
146 stream.write_packetrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/impl#[`MySqlStream<S>`]write_packet().(&[public_key_request_id][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
147 stream.flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]flush().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
148
149 // server sends a public key response
150 let packet = stream.recv_packetrust-analyzer cargo sqlx-mysql 0.8.3 connection/stream/impl#[`MySqlStream<S>`]recv_packet().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
151 let rsa_pub_key = &packet[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
152
153 // xor the password with the given nonce
154 let mut pass = to_ascizrust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/to_asciz().(password);
155
156 let (a, b) = (nonce.first_refrust-analyzer cargo bytes 1.12.1 buf/chain/impl#[`Chain<T, U>`]first_ref().(), nonce.last_refrust-analyzer cargo bytes 1.12.1 buf/chain/impl#[`Chain<T, U>`]last_ref().());
157 let mut nonce = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(a.lenrust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().b.lenrust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes]len().());
158 nonce.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(a);
159 nonce.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(b);
160
161 xor_eqrust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/xor_eq().(&mut pass, &nonce);
162
163 // client sends an RSA encrypted password
164 let pkey = parse_rsa_pub_keyrust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/parse_rsa_pub_key().(rsa_pub_key)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
165 let padding = Oaeprust-analyzer cargo rsa 0.9.10 oaep/Oaep#::newrust-analyzer cargo rsa 0.9.10 oaep/impl#[Oaep]new().::<sha1rust-analyzer cargo sha1 0.10.7 crate/::Sha1rust-analyzer cargo sha1 0.10.7 Sha1#>();
166 pkey.encryptrust-analyzer cargo rsa 0.9.10 key/impl#[RsaPublicKey]encrypt().(&mut thread_rngrust-analyzer cargo rand 0.8.7 rngs/thread/thread_rng().(), padding, &pass[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().)
167 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::protocolrust-analyzer cargo sqlx-core 0.8.3 error/impl#[Error]protocol().)
168 }
169
170 // XOR(x, y)
171 // If len(y) < len(x), wrap around inside y
172 fn xor_eqrust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/xor_eq().(x: &mut [u8], y: &[u8]) {
173 let y_len = y.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
174
175 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#x.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
176 x[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitXorAssign<Self>`]bitxor_assign().y[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().y_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
177 }
178 }
179
180 fn to_ascizrust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/to_asciz().(s: &str) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> {
181 let mut z = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().(s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1);
182 z.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(s);
183 z.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('\0');
184
185 z.into_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]into_bytes().()
186 }
187
188 // https://docs.rs/rsa/0.3.0/rsa/struct.RSAPublicKey.html?search=#example-1
189 fn parse_rsa_pub_keyrust-analyzer cargo sqlx-mysql 0.8.3 connection/auth/parse_rsa_pub_key().(key: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<RsaPublicKeyrust-analyzer cargo rsa 0.9.10 key/RsaPublicKey#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
190 let pem = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(key).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::protocolrust-analyzer cargo sqlx-core 0.8.3 error/impl#[Error]protocol().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
191
192 // This takes advantage of the knowledge that we know
193 // we are receiving a PKCS#8 RSA Public Key at all
194 // times from MySQL
195
196 RsaPublicKeyrust-analyzer cargo rsa 0.9.10 key/RsaPublicKey#::from_public_key_pemrust-analyzer cargo spki 0.7.3 traits/DecodePublicKey#from_public_key_pem().(pem).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::protocolrust-analyzer cargo sqlx-core 0.8.3 error/impl#[Error]protocol().)
197 }