• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the License); you may
5  *  not use this file except in compliance with the License.
6  *
7  *  http://www.apache.org/licenses/LICENSE-2.0
8  */
9 
10 #include <stdio.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <gmssl/mem.h>
14 #include <gmssl/sm2.h>
15 
16 
main(void)17 int main(void)
18 {
19 	SM2_KEY sm2_key;
20 	char *password = "123456";
21 
22 	printf("Read SM2 private key file (PEM) from stdin ...\n");
23 	if (sm2_private_key_info_decrypt_from_pem(&sm2_key, password, stdin) != 1) {
24 		fprintf(stderr, "error\n");
25 		return 1;
26 	}
27 
28 	// openssl ec -pubin -in sm2pub.pem -text
29 	sm2_public_key_info_to_pem(&sm2_key, stdout);
30 
31 	gmssl_secure_clear(&sm2_key, sizeof(sm2_key));
32 	return 0;
33 }
34