aboutsummaryrefslogtreecommitdiff
path: root/third_party/libuweave/src/crypto_utils.c
blob: 76b80680f693973cef9493b3c888525813bc9d4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2015 The Weave Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/crypto_utils.h"

bool uw_crypto_utils_equal_(const uint8_t* arr1,
                            const uint8_t* arr2,
                            size_t len) {
  if (arr1 == NULL || arr2 == NULL) {
    if (arr1 == NULL && arr2 == NULL && len == 0) {
      return true;
    }
    return false;
  }

  uint8_t diff = 0;
  for (size_t i = 0; i < len; i++) {
    diff |= arr1[i] ^ arr2[i];
  }

  return 0 == diff;
}