mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-01 07:24:02 +08:00
39 lines
808 B
C
39 lines
808 B
C
/*
|
|
* Copyright 2014-2023 The GmSSL Project. All Rights Reserved.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the License); you may
|
|
* not use this file except in compliance with the License.
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <gmssl/sm3.h>
|
|
|
|
|
|
int main(void)
|
|
{
|
|
unsigned char key[16] = {
|
|
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
|
|
0x01,0xf2,0x03,0x04,0x05,0x06,0x07,0x08,
|
|
};
|
|
unsigned char data[16] = {
|
|
0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
|
|
0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,
|
|
};
|
|
unsigned char hmac[32] = {0};
|
|
int i;
|
|
|
|
sm3_hmac(key, sizeof(key), data, sizeof(data), hmac);
|
|
|
|
printf("hmac: ");
|
|
for (i = 0; i < sizeof(hmac); i++) {
|
|
printf("%02x", hmac[i]);
|
|
}
|
|
printf("\n");
|
|
|
|
return 0;
|
|
}
|