40 lines
1.9 KiB
C
40 lines
1.9 KiB
C
/* Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
|
|
source code may only be used and distributed under the Widevine License
|
|
Agreement. */
|
|
|
|
#ifndef OEMCRYPTO_TA_OEMCRYPTO_OUTPUT_H_
|
|
#define OEMCRYPTO_TA_OEMCRYPTO_OUTPUT_H_
|
|
|
|
#include "OEMCryptoCENC.h"
|
|
|
|
#include "wtpi_crypto_and_key_management_interface_layer1.h"
|
|
|
|
/* Initializes a new OPK_OutputBuffer and offset from an incoming
|
|
OEMCrypto_DestBufferDesc or returns an error if this is impossible.
|
|
|
|
Returns OEMCrypto_ERROR_INVALID_CONTEXT if the incoming buffer is malformed.
|
|
Returns OEMCrypto_ERROR_NOT_IMPLEMENTED if the incoming buffer is of a type
|
|
not supported by OPK_OutputBuffer. Returns OEMCrypto_SUCCESS otherwise.*/
|
|
OEMCryptoResult OPK_ParseDestBufferDesc(
|
|
const OEMCrypto_DestBufferDesc* incoming, OPK_OutputBuffer* outgoing,
|
|
size_t* offset);
|
|
|
|
/* Verifies that it is safe to write |size| bytes into |output_buffer| at offset
|
|
|offset|. This function not only checks against whether the output buffer is
|
|
large enough but also whether the size violates any of this device's limits.
|
|
It also uses the porting layer to confirm that the output buffer is actually
|
|
writeable with the given offset and size.
|
|
|
|
Returns OEMCrypto_ERROR_INVALID_CONTEXT if the combined size and offset
|
|
cannot fit in a size_t or if the porting layer rejects the write. Returns
|
|
OEMCrypto_ERROR_OUTPUT_TOO_LARGE if the write would exceed one of the
|
|
system's limits. Returns OEMCrypto_ERROR_SHORT_BUFFER if there is not enough
|
|
space in the buffer. Returns OEMCrypto_SUCCESS otherwise.*/
|
|
OEMCryptoResult OPK_CheckOutputBounds(const OPK_OutputBuffer* output_buffer,
|
|
size_t offset, size_t size);
|
|
|
|
/* Verifies that a given OPK_OutputBuffer is well-formed. */
|
|
bool OPK_IsOutputBufferValid(const OPK_OutputBuffer* output_buffer);
|
|
|
|
#endif /* OEMCRYPTO_TA_OEMCRYPTO_OUTPUT_H_ */
|