-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c15a16
commit 2fa1bb5
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,14 @@ LOCAL_CFLAGS += \ | |
|
||
LOCAL_SRC_FILES += \ | ||
KeyBuffer.cpp \ | ||
Keymaster4.cpp | ||
Keymaster4.cpp \ | ||
main.cpp | ||
|
||
LOCAL_SHARED_LIBRARIES += \ | ||
[email protected] \ | ||
libkeymaster4support | ||
libbinder \ | ||
libhidlbase \ | ||
libkeymaster4support \ | ||
libutils | ||
|
||
include $(BUILD_EXECUTABLE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2020 Erfan Abdi <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include "Keymaster4.h" | ||
|
||
/* Maximum allowed keymaster blob size. */ | ||
#define KEYMASTER_BLOB_SIZE 2048 | ||
|
||
#define RSA_KEY_SIZE 2048 | ||
#define RSA_KEY_SIZE_BYTES (RSA_KEY_SIZE / 8) | ||
#define RSA_EXPONENT 0x10001 | ||
#define KEYMASTER_CRYPTFS_RATE_LIMIT 1 // Maximum one try per second | ||
|
||
int main(int argc, char *argv[]) { | ||
unsigned char keymaster_blob[KEYMASTER_BLOB_SIZE]; | ||
unsigned int keymaster_blob_size = 0; | ||
memset(keymaster_blob, 0, KEYMASTER_BLOB_SIZE); | ||
|
||
printf("Generating dummy keypair\n"); | ||
int rc = keymaster_create_key_for_cryptfs_scrypt(RSA_KEY_SIZE, RSA_EXPONENT, KEYMASTER_CRYPTFS_RATE_LIMIT, keymaster_blob, KEYMASTER_BLOB_SIZE, &keymaster_blob_size); | ||
if (rc) { | ||
if (keymaster_blob_size > KEYMASTER_BLOB_SIZE) { | ||
printf("Keymaster key blob to large\n"); | ||
keymaster_blob_size = 0; | ||
} | ||
printf("Failed to generate keypair\n"); | ||
return -1; | ||
} | ||
return 0; | ||
} |