OEMCrypto unit tests for license release

Bug: 295956275
Change-Id: I3c8fc5fcadeae051cc734a64378e473492437c34
This commit is contained in:
Vicky Min
2023-12-05 01:36:58 +00:00
committed by Robert Shih
parent f94a8dfac9
commit d5157c536d
7 changed files with 233 additions and 21 deletions

View File

@@ -609,6 +609,48 @@ class RenewalRoundTrip
bool is_release_; // If this is a license release, and not a real renewal.
};
class ReleaseRoundTrip
: public RoundTrip<
/* CoreRequest */ oemcrypto_core_message::ODK_ReleaseRequest,
OEMCrypto_PrepAndSignReleaseRequest,
// Release response info is same as request:
/* CoreResponse */ oemcrypto_core_message::ODK_ReleaseRequest,
/* ResponseData */ MessageData> {
public:
ReleaseRoundTrip(LicenseRoundTrip* license_messages)
: RoundTrip(license_messages->session()),
license_messages_(license_messages) {}
void CreateDefaultResponse() override;
void EncryptAndSignResponse() override;
OEMCryptoResult LoadResponse() override { return LoadResponse(session_); }
OEMCryptoResult LoadResponse(Session* session) override;
int64_t seconds_since_license_received() const {
return seconds_since_license_received_;
}
void set_seconds_since_license_received(
int64_t seconds_since_license_received) {
seconds_since_license_received_ = seconds_since_license_received;
}
int64_t seconds_since_first_decrypt() const {
return seconds_since_first_decrypt_;
}
void set_seconds_since_first_decrypt(int64_t seconds_since_first_decrypt) {
seconds_since_first_decrypt_ = seconds_since_first_decrypt;
}
protected:
bool RequestHasNonce() override { return false; }
void VerifyRequestSignature(const vector<uint8_t>& data,
const vector<uint8_t>& generated_signature,
size_t core_message_length) override;
// Verify the values of the core response.
virtual void FillAndVerifyCoreRequest(
const std::string& core_message_string) override;
LicenseRoundTrip* license_messages_;
int64_t seconds_since_license_received_;
int64_t seconds_since_first_decrypt_;
};
class EntitledMessage {
public:
EntitledMessage(LicenseRoundTrip* license_messages)