Changeset 94082 in vbox for trunk/src/libs/openssl-3.0.1/include/internal/constant_time.h
- Timestamp:
- Mar 3, 2022 7:17:34 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 150325
- Location:
- trunk/src/libs/openssl-3.0.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/openssl-3.0.1
- Property svn:mergeinfo
-
old new 12 12 /vendor/openssl/1.1.1c:131722-131725 13 13 /vendor/openssl/1.1.1k:145841-145843 14 /vendor/openssl/3.0.1:150323-150324 15 /vendor/openssl/current:147554-150322
-
- Property svn:mergeinfo
-
trunk/src/libs/openssl-3.0.1/include/internal/constant_time.h
r91772 r94082 1 1 /* 2 * Copyright 2014-20 19The OpenSSL Project Authors. All Rights Reserved.3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use2 * Copyright 2014-2021 The OpenSSL Project Authors. All Rights Reserved. 3 * 4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 10 10 #ifndef OSSL_INTERNAL_CONSTANT_TIME_H 11 11 # define OSSL_INTERNAL_CONSTANT_TIME_H 12 # pragma once 12 13 13 14 # include <stdlib.h> … … 182 183 } 183 184 185 static ossl_inline uint64_t constant_time_is_zero_64(uint64_t a) 186 { 187 return constant_time_msb_64(~a & (a - 1)); 188 } 189 184 190 static ossl_inline unsigned int constant_time_eq(unsigned int a, 185 191 unsigned int b) … … 354 360 355 361 /* 362 * mask must be 0xFF or 0x00. 363 * "constant time" is per len. 364 * 365 * if (mask) { 366 * unsigned char tmp[len]; 367 * 368 * memcpy(tmp, a, len); 369 * memcpy(a, b); 370 * memcpy(b, tmp); 371 * } 372 */ 373 static ossl_inline void constant_time_cond_swap_buff(unsigned char mask, 374 unsigned char *a, 375 unsigned char *b, 376 size_t len) 377 { 378 size_t i; 379 unsigned char tmp; 380 381 for (i = 0; i < len; i++) { 382 tmp = a[i] ^ b[i]; 383 tmp &= mask; 384 a[i] ^= tmp; 385 b[i] ^= tmp; 386 } 387 } 388 389 /* 356 390 * table is a two dimensional array of bytes. Each row has rowsize elements. 357 391 * Copies row number idx into out. rowsize and numrows are not considered
Note:
See TracChangeset
for help on using the changeset viewer.