?? rsakeygen.c
字號:
/* $Id: rsakeygen.c,v 1.6 2000/04/06 07:26:53 jm Exp $ * RSA key generation tool * * Dynamic hierarchial IP tunnel * Copyright (C) 1998-2000, Dynamics group * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. See README and COPYING for * more details. */#include <stdlib.h>#include <stdio.h>#include <string.h>#include "rsa_dyn.h"#include "message.h"#include "md5_mac.h"#include "util.h"int main(int argc, char *argv[]){ int bits, i; struct msg_key *fa_public_key = NULL; unsigned char mac[MD5_MAC_LEN]; if (argc != 3) { fprintf(stderr, "usage\n" "rsakeygen <keyfile name> <key len in bits>\n" "e.g. rsakeygen /etc/dynfad.key 768\n"); exit(1); } bits = atoi(argv[2]); printf("Generating %i bits long RSA key to file %s\n", bits, argv[1]); if (rsa_make_key(argv[1], bits) != 0) { fprintf(stderr, "RSA key generation failed\n"); exit(1); } else { printf("RSA key generated successfully\n"); } /* Get the FA public key */ i = rsa_initialize(argv[1]); if (i != 0) { fprintf(stderr, "RSA initialization failed (key file: %s, " "code: %i)\n", argv[1], i); exit(1); } fa_public_key = (struct msg_key *) malloc(sizeof(struct msg_key) + SPI_LEN + rsa_get_public_key_len() + 1); if (fa_public_key == NULL) { fprintf(stderr, "Not enough memory for fa_public_key\n"); exit(1); } if (rsa_get_public_key_len() + SPI_LEN > 255) { fprintf(stderr, "fa_public_key over 255 bytes long - does " "not fit into extension\n"); exit(1); } init_key_extension(fa_public_key, VENDOR_EXT_DYNAMICS_FA_PUBKEY, htonl(PUBKEY_ALG_SPI_RSA), rsa_get_public_key_len()); memcpy(MSG_KEY_DATA(fa_public_key), rsa_get_public_key(), GET_KEY_LEN(fa_public_key)); md5_mac((unsigned char *) "", 0, (unsigned char *) fa_public_key, GET_KEY_EXT_LEN(fa_public_key), mac); printf("RSA public key extension hash: "); for (i = 0; i < MD5_MAC_LEN; i++) printf("%02X", mac[i]); printf("\n"); free(fa_public_key); return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -