sanity checks on encrypted message size
| 222 | |
| 223 | // sanity checks on encrypted message size |
| 224 | static 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 |
no test coverage detected