First Publicly Shared Version of ODKiTEE v15
This commit is contained in:
26
oemcrypto_ta/oemcrypto_endianness.c
Normal file
26
oemcrypto_ta/oemcrypto_endianness.c
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#include "oemcrypto_endianness.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
uint32_t HostToNetworkU32(uint32_t host) {
|
||||
uint8_t bytes[] = {
|
||||
(uint8_t)(host >> 24u),
|
||||
(uint8_t)(host >> 16u),
|
||||
(uint8_t)(host >> 8u),
|
||||
(uint8_t)(host >> 0u),
|
||||
};
|
||||
|
||||
uint32_t network;
|
||||
memcpy(&network, bytes, sizeof(network));
|
||||
return network;
|
||||
}
|
||||
|
||||
uint32_t NetworkToHostU32(uint32_t network) {
|
||||
// These functions are symmetrical on any byte-ordering used in practice.
|
||||
return HostToNetworkU32(network);
|
||||
}
|
||||
Reference in New Issue
Block a user