MCPcopy Create free account
hub / github.com/docknetwork/crypto / fill_bytes

Method fill_bytes

oblivious_transfer/src/aes_prng.rs:185–205  ·  view source on GitHub ↗

Fills in an array of bytes with randomness

(&mut self, dest: &mut [u8])

Source from the content-addressed store, hash-verified

183
184 /// Fills in an array of bytes with randomness
185 fn fill_bytes(&mut self, dest: &mut [u8]) {
186 let mut read_len = STATE_SIZE - self.state.used_bytes;
187 let mut dest_start = 0;
188
189 while read_len < dest.len() {
190 let src_start = self.state.used_bytes;
191 dest[dest_start..read_len]
192 .copy_from_slice(&self.state.as_mut_bytes()[src_start..STATE_SIZE]);
193 self.next();
194 dest_start = read_len;
195 read_len += STATE_SIZE;
196 }
197
198 let src_start = self.state.used_bytes;
199 let remainder = dest.len() - dest_start;
200 let dest_len = dest.len();
201
202 dest[dest_start..dest_len]
203 .copy_from_slice(&self.state.as_mut_bytes()[src_start..src_start + remainder]);
204 self.state.used_bytes += remainder;
205 }
206
207 fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
208 self.fill_bytes(dest);

Callers 10

commitMethod · 0.45
try_fill_bytesMethod · 0.45
fill_q_matrixMethod · 0.45
checkFunction · 0.45
checkFunction · 0.45
encryptMethod · 0.45
checkFunction · 0.45
checkFunction · 0.45

Calls 3

as_mut_bytesMethod · 0.80
nextMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected