0

私が行っているプロジェクトのAESの実装を見つけました。

ただし、統合すると、ビルド中に次のエラーが発生します。

In file included from ff.h:26:0,
             from disp.h:4,
             from main.c:14:
aes.h:14:3: error: conflicting types for 'AesCtx'
aes.h:14:3: note: previous declaration of 'AesCtx' was here
aes.h:28:5: error: conflicting types for 'AesCtxIni'
aes.h:28:5: note: previous declaration of 'AesCtxIni' was here
aes.h:29:5: error: conflicting types for 'AesEncrypt'
aes.h:29:5: note: previous declaration of 'AesEncrypt' was here
aes.h:30:5: error: conflicting types for 'AesDecrypt'
aes.h:30:5: note: previous declaration of 'AesDecrypt' was here

ヘッダーファイル自体は次のとおりです。

// AES context structure
typedef struct {
 unsigned int Ek[60];
 unsigned int Dk[60];
 unsigned int Iv[4];
 unsigned char Nr;
 unsigned char Mode;
} AesCtx;

// key length in bytes
#define KEY128 16
#define KEY192 24
#define KEY256 32
// block size in bytes
#define BLOCKSZ 16
// mode
#define EBC 0
#define CBC 1

// AES API function prototype

int AesCtxIni(AesCtx *pCtx, unsigned char *pIV, unsigned char *pKey, unsigned int KeyLen, unsigned char Mode);
int AesEncrypt(AesCtx *pCtx, unsigned char *pData, unsigned char *pCipher, unsigned int DataLen);
int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen);

次に、それぞれのCファイルがを使用します。

int AesCtxIni(AesCtx *pCtx, unsigned char *pIV, unsigned char *pKey, unsigned int KeyLen, unsigned char Mode)
{
    // Cut out code for brevity
}

int AesEncrypt(AesCtx *pCtx, unsigned char *pData, unsigned char *pCipher, unsigned int DataLen)
{
    // Cut out code for brevity
}

int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen)
{
    // Cut out code for brevity
}

これらのエラーは通常、関数が事前に宣言されていないか、関数の宣言とわずかに異なるために発生することを知っていますが、違いはわかりません。

何か案は?

4

1 に答える 1

5

どのコンパイラを使用していますか? それが言おうとしている私の最善の推測は、2回daes.hされていることです。#includeの最初と最後にヘッダー ガードを追加してみてくださいaes.h

#ifndef AES_H_
#define AES_H_

typedef struct {
...
int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen);

#endif /* !AES_H_ */
于 2013-02-13T09:01:59.067 に答える