/src/libssh/src/crypto_common.c
Line | Count | Source |
1 | | /* |
2 | | * This file is part of the SSH Library |
3 | | * |
4 | | * Copyright (c) 2020 by Anderson Toshiyuki Sasaki - Red Hat, Inc. |
5 | | * |
6 | | * This library is free software; you can redistribute it and/or |
7 | | * modify it under the terms of the GNU Lesser General Public |
8 | | * License as published by the Free Software Foundation; either |
9 | | * version 2.1 of the License, or (at your option) any later version. |
10 | | * |
11 | | * This library is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | | * Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public |
17 | | * License along with this library; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | | */ |
20 | | |
21 | | #include "config.h" |
22 | | #include "libssh/crypto.h" |
23 | | |
24 | | int secure_memcmp(const void *s1, const void *s2, size_t n) |
25 | 0 | { |
26 | 0 | size_t i; |
27 | 0 | uint8_t status = 0; |
28 | 0 | const uint8_t *p1 = s1; |
29 | 0 | const uint8_t *p2 = s2; |
30 | |
|
31 | 0 | for (i = 0; i < n; i++) { |
32 | 0 | status |= (p1[i] ^ p2[i]); |
33 | 0 | } |
34 | |
|
35 | 0 | return (status != 0); |
36 | 0 | } |