#include stdio.h"stdlib.h" #include stdio.h"stdio.h" struct list { int data; struct list *

I'm just started to work with IAR compiler and ARM microControllers. In the first step I want to do an RSA encryption using my AT91SAM7S MCU (I know that this is not a good first step! ;) ).
Anyway, after Googling I found
site containing two files named rsa.h
and rsa.c that implement RSA algorithm for Embedded devices.
So I download this files and put them in the directory of my program, (In the same directory that main.c is).
Now, when I trying to build and compile this project, I face the following errors :
Building configuration: 4rsa - Debug
Updating build tree...
file(s) deleted.
Updating build tree...
Error[Pe020]: identifier "uint64_t" is undefined C:\4rsa\rsa.h 22
Error while running C/C++ Compiler
Fatal Error[Pe005]: could not open source file "cross_studio_io.h" C:\4rsa\rsa.c 22
Error while running C/C++ Compiler
Total number of errors: 2
Total number of warnings: 0
Total number of errors: 2
Total number of warnings: 0
It seems that I must download and add some libraries to my program, but I don't have any idea which libraries I am need and where I can download them.
This is contents of rsa.h:
/**************************************************************************/
Kyle Loudon
modified: microBuilder.eu
4 January, 2010
Basic RSA-encryption using 64-bit math (32-bit keys).
Based on the examples from "Mastering Algorithms with C" by
Kyle Loudon (O'Reilly, 1999).
/**************************************************************************/
#include &stdlib.h&
#ifndef _RSA_H_
#define _RSA_H_
/* In a secure implementation, huge_t should be at least 400 decimal digits, *
* instead of the 20 provided by a 64-bit value.
This means that key values *
* can be no longer than 10 digits in length in the current implementation.
typedef uint64_t huge_t;
/* Structure for RSA public keys. */
typedef struct rsaPubKey_s
rsaPubKey_t;
/* Define a structure for RSA private keys. */
typedef struct rsaPriKey_s
rsaPriKey_t;
void rsaTest();
void rsaEncrypt(huge_t plaintext, huge_t *ciphertext, rsaPubKey_t pubkey);
void rsaDecrypt(huge_t ciphertext, huge_t *plaintext, rsaPriKey_t prikey);
This is contents of rsa.c:
/**************************************************************************/
Kyle Loudon
modified: microBuilder.eu
4 January, 2010
Basic RSA-encryption using 64-bit math (32-bit keys).
Based on the examples from "Mastering Algorithms with C" by
Kyle Loudon (O'Reilly, 1999).
Note: The rsaTest function uses debug_printf in Rowley Associate's
Crossworks for ARM.
If you wish to use an alternative means to
display the test results, cross_studio_io.h can be removed from the
include list, and debug_printf can be renamed to a different
output method.
/**************************************************************************/
#include &cross_studio_io.h&
#include "rsa.h"
static huge_t modexp(huge_t a, huge_t b, huge_t n)
Compute pow(a, b) % n using the binary square and multiply method. */
while (b != 0)
For each 1 in b, accumulate y. */
if (b & 1)
y = (y * a) %
/* Square a for each bit in b. */
a = (a * a) %
Prepare for the next bit in b. */
b = b && 1;
void rsaTest()
rsaOrig, rsaDecrypted, rsaE
rsaPubKey_t publicK
rsaPriKey_t privateK
debug_printf("Encrypting with RSA\n");
// Values based on 64-bit math (huge_t = unsigned long long)
// which will result in more secure encryption, but also
// increases the size of the encrypted text
publicKey.e = 21;
publicKey.n = ;
privateKey.d = ;
privateKey.n = ;
// Alternative values with 32-bit math (huge_t = unsigned long)
// or when smaller encrypted text is desired
// publicKey.e = 17;
// publicKey.n = 209;
// privateKey.d = 53;
// privateKey.n = 209;
debug_printf("d=%lld, e=%lld, n=%lld\n",
privateKey.d, publicKey.e, publicKey.n);
for (i = 0; i & 128; i++)
rsaEncrypt(rsaOrig, &rsaEncrypted, publicKey);
rsaDecrypt(rsaEncrypted, &rsaDecrypted, privateKey);
if (rsaOrig == rsaDecrypted)
debug_printf("In=%5lld, Encrypted=%10lld, Out=%5lld (OK)\n",
rsaOrig, rsaEncrypted, rsaDecrypted);
debug_printf("In=%5lld, Encrypted=%10lld, Out=%5lld (ERROR)\n",
rsaOrig, rsaEncrypted, rsaDecrypted);
void rsaEncrypt(huge_t plaintext, huge_t *ciphertext, rsaPubKey_t pubkey)
*ciphertext = modexp(plaintext, pubkey.e, pubkey.n);
void rsaDecrypt(huge_t ciphertext, huge_t *plaintext, rsaPriKey_t prikey)
*plaintext = modexp(ciphertext, prikey.d, prikey.n);
And this is my IAR IDE output:
How can I handle these errors?
Please help me to getting started with this device.
Thanks in advance.
解决方案 rsa.h is incorrectly written. It needs to include stdint.h. This is not related to IAR, ARM or anything else.
本文地址: &
我刚开始与IAR编译器和ARM微控制器的工作。在第一步中,我想用做一个RSA加密我的 AT91SAM7S 的MCU(我知道这是不是一个很好的第一步;!)。)总之,谷歌搜索后,我发现网站名为 rsa.h 和 rsa.c 实现RSA算法的嵌入式设备。 于是我下载这个文件,并把它们放在我的程序的目录,(在同一目录中的的main.c 是)。现在,当我试图建立和编译这个项目,我遇到以下错误:大厦的配置:4rsa
- 调试更新构建树...
3档(S)删除。更新建树...main.c中错误[Pe020]:标识符“uint64_t中”是不确定的C:\\ 4rsa \\ rsa.h 22在运行C / C ++编译器错误rsa.c致命错误[Pe005]:无法打开源文件“cross_studio_io.h”C:\\ 4rsa \\ rsa.c 22在运行C / C ++编译器错误总数错误:2总数警告:0总数错误:2总数警告:0 看来我必须下载并添加一些库到我的计划,但我没有哪些库,我需要和我在哪里可以下载他们的任何想法。
FYI:这是内容 rsa.h :
/ ********* ********* // *!
\\文件rsa.h
\\作者凯尔劳登
修改:microBuilder.eu
使用64位数学(32位密钥)基本RSA的加密。
根据来自“精通算法与C”的例子
凯尔劳登(O'Reilly出版,1999)。* // ******************* ******** /#包括LT&;&stdlib.h中GT;的#ifndef _RSA_H_#定义_RSA_H_/ *在一个安全的执行,huge_t应该至少400十进制数字,* *而不是由一个64位的值提供的20。这意味着它们键值* *可以比10位数字的长度在当前实现中不再。 * /的typedef uint64_t中huge_t;/ *为RSA公共密钥结构。 * /typedef结构rsaPubKey_s{
huge_t N;}rsaPubKey_t;/ *定义一个结构,RSA私钥。 * /typedef结构rsaPriKey_s{
huge_t D组;
huge_t N;}rsaPriKey_t;无效rsaTest();无效rsaEncrypt(huge_t明文,huge_t *密文,rsaPubKey_t PUBKEY);无效rsaDecrypt(huge_t密文,huge_t *明文,rsaPriKey_t prikey);#万一 这是内容 rsa.c :
/ ********* ********* // *!
\\文件rsa.c
\\作者凯尔劳登
修改:microBuilder.eu
使用64位数学(32位密钥)基本RSA的加密。
根据来自“精通算法与C”的例子
凯尔劳登(O'Reilly出版,1999)。
注:rsaTest功能使用debug_printf在罗利联营公司
CrossWorks的为ARM。如果你想使用另一种手段来
显示测试结果,cross_studio_io.h可以从被删除
包括列表,debug_printf可以被重命名为不同的
输出方式。* // ******************* ******** /#包括LT&;&cross_studio_io.h GT;#包括“rsa.h”静态huge_t modexp(huge_t一,huge_t B,huge_t N){
/ *计算POW(A,B)%N使用二进制广场和繁殖方法。 * /
状态,(b!= 0)
/ *您在B各1所,累计年。 * /
如果(B&安培; 1)
Y =(Y * A)%N;
/ *您在B每一位广场。 * /
A =(A * A)%N;
/ * prepare在b中的下一位。 * /
B = B个;> 1;
返回是;}无效rsaTest(){
huge_t rsaOrig,rsaDecrypted,rsaE
rsaPubKey_t公钥;
rsaPriKey_t privateK
debug_printf(“与RSA \\ n加密”);
基于64位数学//值(huge_t =无符号很长很长)
//这将导致更安全的加密,但也
//增加了加密的文本的大小
publicKey.e = 21;
publicKey.n = ;
privateKey.d = ;
privateKey.n = ;
// 32位数学(huge_t =无符号长)替代值
//或者更小的加密的文本需要
// publicKey.e = 17;
// publicKey.n = 209;
// privateKey.d = 53;
// privateKey.n = 209;
debug_printf(“D =%LLD,E =%LLD,N =%LLD \\ n”
privateKey.d,publicKey.e,publicKey.n);
对于(i = 0; I< 128;我++)
rsaOrig = I;
rsaEncrypt(rsaOrig,&安培; rsaEncrypted,公钥);
rsaDecrypt(rsaEncrypted,&安培; rsaDecrypted,privateKey);
如果(rsaOrig == rsaDecrypted)
debug_printf(“时间=%5lld,加密=%10lld,时间=%5lld(OK)\\ n”
rsaOrig,rsaEncrypted,rsaDecrypted);
debug_printf(“时间=%5lld,加密=%10lld,时间=%5lld(错误)\\ n”
rsaOrig,rsaEncrypted,rsaDecrypted);
}}无效rsaEncrypt(huge_t明文,huge_t *密文,rsaPubKey_t PUBKEY){
*密文= modexp(明文,pubkey.e,pubkey.n);
返回;}无效rsaDecrypt(huge_t密文,huge_t *明文,rsaPriKey_t prikey){
*明文= modexp(密文,prikey.d,prikey.n);
返回;} 这是我的IAR IDE输出:
我该如何处理这些错误?请帮我开始使用此设备。先谢谢了。解决方案
rsa.h 编写不当。它需要包括 stdint.h 。这是不相关的IAR,ARM或其他任何东西。
本文地址: &
扫一扫关注官方微信图书管理系统_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
图书管理系统
上传于||文档简介
&&图​书​管​理​系​统
阅读已结束,如果下载本文需要使用5下载券
想免费下载本文?
定制HR最喜欢的简历
你可能喜欢请教,交流#include&stdio.h&#include&stdlib.h&int main(){FILE*fp=fopen(&data.in&, &r&);int i, j,char bin[100000];if(fp==NULL){printf(&Error 1\n&);fclose(fp);return 1;}fscanf(fp,&%u&,&j);if(j&=0||j&=100000){printf(&Error 2\n&);fclose(fp);return 2;}sum=0;for(i=0;i&sizeof(int)*8;++i)if(j & 1&&i) sum++;printf(&%d:%d\n&,j ,sum);return 0;这是求10进制转换成2进制的程序,并计算输出的2进制中有多少个1,还有一个问题,如果是转换成16进制或8进制呢&
&为什么这个语句就转换成了2进制了呢
回答1:j & 1$<$i 这种是 位运算,楼主可以去了解下。。
rosetears2
我这里有完全代码,我也写过的 ----》#include&stdio.h&
//This is the operation of changing a number to another#include&stdlib.h&#define MAXSIZE 100typedef struct
int data[MAXSIZE];
//This is the defination of Stack and Queue}SeqStack,*PSeqStypedef struct& {
int data[MAXSIZE];
int front,}SeqQueue,*PSeqQPSeqQueue Init_SeqQueue(void)
//To Init a SeqQueue{
PSeqQueue Q;
Q=(PSeqQueue) malloc(sizeof(SeqQueue));
Q-&front=0;
Q-&rear=0;
return Q;}int Empty_SeqQueue(PSeqQueue Q)
//To estimate a SeqQueue{
if( Q && Q-&front == Q-&rear )
return 0;}int In_SeqQueue(PSeqQueue Q,int x)
//To insert a element to a Queue{&
if( (Q-&rear+1) % MAXSIZE
Q-&front )
printf(&The Queue is full&);
return -1;
Q-&rear = ( Q-&rear+1 ) % MAXSIZE;
Q-&data[Q-&rear]=x;
}}int Out_SeqQueue(PSeqQueue Q,int *x)
//To output a element from a Queue{
if(Empty_SeqQueue(Q))
printf(&The Queue is empty&);
return -1;
Q-&front=(Q-&front+1)%MAXSIZE;
*x=Q-&data[Q-&front];
}}void Destroy_SeqQueue(PSeqQueue *Q)
//To destroy a Queue you have created{
*Q=NULL;}PSeqStack Init_SeqStack(void)
/*To create a Stack*/{ PSeqStack S; S=(PSeqStack) malloc(sizeof(SeqStack)); if(S) {
S-&top=-1;
return S; }}int Push_SeqStack(PSeqStack S,int x)
/*To insert a element to Stack*/{
if(S-&top==MAXSIZE-1)
return 0; else {
S-&data[S-&top]=x;
return 1; }}int Empty_SeqStack(PSeqStack S)
//To estimate a Stack is empty or not{
if(S-&top==-1)
return 1; else&
return 0;}}

我要回帖

更多关于 includestdlib 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信