mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-23 00:47:31 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
63
mobile/ios/ThirdParty/ecec/tool/keygen.c
vendored
Normal file
63
mobile/ios/ThirdParty/ecec/tool/keygen.c
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ece.h>
|
||||
|
||||
static const char ece_keygen_hex_alphabet[] = "0123456789abcdef";
|
||||
|
||||
char*
|
||||
ece_keygen_hex_encode(const uint8_t* binary, size_t binaryLen) {
|
||||
if (binaryLen > SIZE_MAX / 2 - 1) {
|
||||
return NULL;
|
||||
}
|
||||
char* encoded = malloc(binaryLen * 2 + 1);
|
||||
if (!encoded) {
|
||||
return NULL;
|
||||
}
|
||||
char* hex = encoded;
|
||||
for (size_t i = 0; i < binaryLen; i++) {
|
||||
*hex++ = ece_keygen_hex_alphabet[(binary[i] >> 4) & 0xf];
|
||||
*hex++ = ece_keygen_hex_alphabet[binary[i] & 0xf];
|
||||
}
|
||||
*hex = '\0';
|
||||
return encoded;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv) {
|
||||
uint8_t rawRecvPrivKey[ECE_WEBPUSH_PRIVATE_KEY_LENGTH];
|
||||
uint8_t rawRecvPubKey[ECE_WEBPUSH_PUBLIC_KEY_LENGTH];
|
||||
uint8_t authSecret[ECE_WEBPUSH_AUTH_SECRET_LENGTH];
|
||||
|
||||
int err = ece_webpush_generate_keys(
|
||||
rawRecvPrivKey, ECE_WEBPUSH_PRIVATE_KEY_LENGTH, rawRecvPubKey,
|
||||
ECE_WEBPUSH_PUBLIC_KEY_LENGTH, authSecret, ECE_WEBPUSH_AUTH_SECRET_LENGTH);
|
||||
if (err) {
|
||||
fprintf(stderr, "Error: Failed to generate subscription keys: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* hexRecvPrivKey =
|
||||
ece_keygen_hex_encode(rawRecvPrivKey, ECE_WEBPUSH_PRIVATE_KEY_LENGTH);
|
||||
if (hexRecvPrivKey) {
|
||||
printf("Private key: %s\n", hexRecvPrivKey);
|
||||
}
|
||||
|
||||
char* hexRecvPubKey =
|
||||
ece_keygen_hex_encode(rawRecvPubKey, ECE_WEBPUSH_PUBLIC_KEY_LENGTH);
|
||||
if (hexRecvPubKey) {
|
||||
printf("Public key: %s\n", hexRecvPubKey);
|
||||
}
|
||||
|
||||
char* hexAuthSecret =
|
||||
ece_keygen_hex_encode(authSecret, ECE_WEBPUSH_AUTH_SECRET_LENGTH);
|
||||
if (hexAuthSecret) {
|
||||
printf("Authentication secret: %s\n", hexAuthSecret);
|
||||
}
|
||||
|
||||
free(hexRecvPrivKey);
|
||||
free(hexRecvPubKey);
|
||||
free(hexAuthSecret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue