Merging CL https://widevine-internal-review.googlesource.com/c/cdm/+/100924 Fix implicit type conversion issue in ODK 1. Implicit cast is reported as error when compiling ODK with Level3 2. Override odk_add_overflow_xxx function with the built in functions can cause redefinition issue when compiling Level3; Let's use odk customized overflow functions. Bug: b/157510403 Test: ODK unittests and CDM unittests passed. Change-Id: Ieef8ccfb41d08007ec72f4a061f92968e55539cb
35 lines
914 B
C
35 lines
914 B
C
/* Copyright 2019 Google LLC. All rights reserved. This file and proprietary */
|
|
/* source code may only be used and distributed under the Widevine Master */
|
|
/* License Agreement. */
|
|
|
|
#include "odk_util.h"
|
|
|
|
int crypto_memcmp(const void* in_a, const void* in_b, size_t len) {
|
|
if (len == 0) {
|
|
return 0;
|
|
}
|
|
|
|
/* Only valid pointers are allowed. */
|
|
if (in_a == NULL || in_b == NULL) {
|
|
return -1;
|
|
}
|
|
|
|
const uint8_t* a = (const uint8_t*)in_a;
|
|
const uint8_t* b = (const uint8_t*)in_b;
|
|
uint8_t x = 0;
|
|
|
|
for (size_t i = 0; i < len; i++) {
|
|
x |= a[i] ^ b[i];
|
|
}
|
|
return x;
|
|
}
|
|
|
|
bool ODK_NonceValuesEqual(const ODK_NonceValues* a, const ODK_NonceValues* b) {
|
|
if (a == NULL || b == NULL) {
|
|
return (a == b);
|
|
}
|
|
return (a->api_major_version == b->api_major_version &&
|
|
a->api_minor_version == b->api_minor_version &&
|
|
a->nonce == b->nonce && a->session_id == b->session_id);
|
|
}
|