📄 keygen.c
字号:
/* <LIC_AMD_STD> * Copyright (C) 2003-2005 Advanced Micro Devices, Inc. All Rights Reserved. * * Unless otherwise designated in writing, this software and any related * documentation are the confidential proprietary information of AMD. * THESE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY * UNLESS OTHERWISE NOTED IN WRITING, EXPRESS OR IMPLIED WARRANTY OF ANY * KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, * NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE AND IN NO * EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER. * * AMD does not assume any responsibility for any errors which may appear * in the Materials nor any responsibility to support or update the * Materials. AMD retains the right to modify the Materials at any time, * without notice, and is not obligated to provide such modified * Materials to you. AMD is not obligated to furnish, support, or make * any further information available to you. * </LIC_AMD_STD> *//* <CTL_AMD_STD> * </CTL_AMD_STD> *//* <DOC_AMD_STD> * </DOC_AMD_STD> */#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include "secure_serial.h"#include "secure_serial_priv.h"int main(int argc, char *argv[]){ int fd; int rc; unsigned char keyArray[KEY_SIZE]; FILE *fs; int i; char comma = ' '; fd = open("/dev/urandom",O_RDONLY); if (fd < 0) { perror("open"); return(-1); } rc = read(fd,&keyArray,sizeof(keyArray)); if ( rc == -1) { perror("read"); return(-2); } close(fd); fs = fopen("/serialnumber.txt","a"); if (NULL == fs) { perror("fopen"); return(-253); } printf("unsigned char keyArray[KEY_SIZE] = {\n"); for(i=0;i<KEY_SIZE;i++) { printf("%c%d",comma,keyArray[i]); comma = ','; } printf("};\n"); printf("hostid = %x\n",gethostid()); fclose(fs); return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -