See https://developers.google.com/widevine/drm/client/opk for documentation and an integration guide.
46 lines
2.0 KiB
C
46 lines
2.0 KiB
C
/* Copyright 2019 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_RSA_UTIL_H_
|
|
#define OEMCRYPTO_TA_RSA_UTIL_H_
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "openssl/rsa.h"
|
|
|
|
/* Logs any errors reported to the thread's error queue. */
|
|
void dump_ssl_error(void);
|
|
|
|
/* Checks to see that |rsa| is a valid RSA key. Returns false if |rsa| is not a
|
|
valid key.
|
|
Caller retains ownership of *|rsa| and it must not be NULL. */
|
|
bool CheckRSAKey(const RSA* rsa);
|
|
|
|
/* Attempts to deserialize |size| bytes of |serialized_bytes| into an RSA key
|
|
and store the result in |rsa|. |serialized_bytes| is expected to be a PKCS8
|
|
RSA private key. Returns false if |serialized_bytes| can not be deserialized.
|
|
|size| must be > 0.
|
|
Caller retains ownership of all pointers and they must not be NULL. */
|
|
bool DeserializePKCS8PrivateKey(const uint8_t* serialized_bytes, size_t size,
|
|
RSA** rsa);
|
|
|
|
/* Signs |message_length| bytes of |message| using |rsa| and padding scheme
|
|
RSASSA-PSS with SHA1 and places the result in |signature| and modifies
|
|
*|signature_length| to the appropriate value.
|
|
Returns false if the signature could not be computed.
|
|
|message_length| must be > 0 and *|signature_length| must be > RSA_size(rsa).
|
|
Caller retains ownership of all pointers and they must not be NULL. */
|
|
bool RSASignSSAPSSSHA1(RSA* rsa, const uint8_t* message, size_t message_length,
|
|
uint8_t* signature, size_t* signature_length);
|
|
|
|
/* Decrypts |in_length| bytes of |in| and places it in |out| using scheme PKCS1
|
|
OAEP and |rsa|. Modifies *|out_length| to the appropriate length.
|
|
|in_length| must be > 0 and *|out_length| must be > RSA_size(rsa).
|
|
Caller retains ownership of all pointers and they must not be NULL. */
|
|
bool RSAPrivateDecrypt(RSA* rsa, const uint8_t* in, size_t in_length,
|
|
uint8_t* out, size_t* out_length);
|
|
|
|
#endif /* OEMCRYPTO_TA_RSA_UTIL_H_ */
|