/rust/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/crypto/mem.c
Line  | Count  | Source  | 
1  |  | // Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.  | 
2  |  | //  | 
3  |  | // Licensed under the Apache License, Version 2.0 (the "License");  | 
4  |  | // you may not use this file except in compliance with the License.  | 
5  |  | // You may obtain a copy of the License at  | 
6  |  | //  | 
7  |  | //     https://www.apache.org/licenses/LICENSE-2.0  | 
8  |  | //  | 
9  |  | // Unless required by applicable law or agreed to in writing, software  | 
10  |  | // distributed under the License is distributed on an "AS IS" BASIS,  | 
11  |  | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  | 
12  |  | // See the License for the specific language governing permissions and  | 
13  |  | // limitations under the License.  | 
14  |  |  | 
15  |  | #include <ring-core/mem.h>  | 
16  |  | #include "internal.h"  | 
17  |  |  | 
18  | 0  | int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len) { | 
19  | 0  |   const aliasing_uint8_t *a = in_a;  | 
20  | 0  |   const aliasing_uint8_t *b = in_b;  | 
21  | 0  |   uint8_t x = 0;  | 
22  |  | 
  | 
23  | 0  |   for (size_t i = 0; i < len; i++) { | 
24  | 0  |     x |= a[i] ^ b[i];  | 
25  | 0  |   }  | 
26  |  | 
  | 
27  | 0  |   return x;  | 
28  | 0  | }  |