MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / sanity_check_message

Function sanity_check_message

extra/yassl/src/handshake.cpp:224–248  ·  view source on GitHub ↗

sanity checks on encrypted message size

Source from the content-addressed store, hash-verified

222
223// sanity checks on encrypted message size
224static int sanity_check_message(SSL& ssl, uint msgSz)
225{
226 uint minSz = 0;
227
228 if (ssl.getSecurity().get_parms().cipher_type_ == block) {
229 uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();
230 if (msgSz % blockSz)
231 return -1;
232
233 minSz = ssl.getSecurity().get_parms().hash_size_ + 1; // pad byte too
234 if (blockSz > minSz)
235 minSz = blockSz;
236
237 if (ssl.isTLSv1_1())
238 minSz += blockSz; // explicit IV
239 }
240 else { // stream
241 minSz = ssl.getSecurity().get_parms().hash_size_;
242 }
243
244 if (msgSz < minSz)
245 return -1;
246
247 return 0;
248}
249
250
251// decrypt input message in place, store size in case needed later

Callers 1

decrypt_messageFunction · 0.85

Calls 3

get_parmsMethod · 0.80
isTLSv1_1Method · 0.80
get_blockSizeMethod · 0.45

Tested by

no test coverage detected