サンプルのオブジェクトnfutil.oを除外し、そのうちの関数nfutil_copybytesだけもらってくる

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@148 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
kubodera_yuichi 2010-01-07 00:51:19 +00:00
parent e4e240482b
commit 1f5eba052d
2 changed files with 58 additions and 8 deletions

View File

@ -50,11 +50,6 @@ NFAST_LDLIBS = \
$(NFAST_LIBPATH)/libnflog.a \
$(NFAST_LIBPATH)/libcutils.a -lm \
# nFast OBJS
NFAST_OBJS_PATH = $(NFAST_EXAMPLES)/nfuser/build-gcc-lib
NFAST_OBJS_LIST = \
$(NFAST_OBJS_PATH)/nfutil.o \
else # !USE_HSM
# HSMが使用できない場合は、DUMMY_KEYを使ってテストする。
@ -140,7 +135,7 @@ package_build :
endif
$(TARGET): $(OBJS)
$(LD) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS) $(NFAST_OBJS_LIST)
$(LD) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS)
$(OBJS): $(HEADS) Makefile

View File

@ -34,6 +34,61 @@ static int alloc_counter = 0;
/* --------------------- */
// original : nfutil_copybytes ( nfutil.c )
static void my_util_copybytes ( unsigned char *dst, const unsigned char *src,
unsigned nbytes, int swapends, int swapwords )
{
int inc;
unsigned nwords;
/* Copies dst to src, swapping endianness and/or word order. dst and src mustn't overlap! */
assert( (nbytes & 3)==0 ); /* Must be whole number of M_Words */
if ( !swapends && !swapwords )
{
memcpy(dst, src, nbytes);
return;
}
if ( swapwords )
{
dst += (nbytes-4);
inc=-4;
}
else
inc=4;
nwords = nbytes>>2;
if ( swapends )
{
while ( nwords-- > 0 )
{
dst[0]=src[3];
dst[1]=src[2];
dst[2]=src[1];
dst[3]=src[0];
dst += inc;
src += 4;
}
}
else
{
while ( nwords-- > 0 )
{
dst[0]=src[0];
dst[1]=src[1];
dst[2]=src[2];
dst[3]=src[3];
dst += inc;
src += 4;
}
}
}
/* --------------------- */
int my_bignumreceiveupcall(struct NFast_Application *app,
struct NFast_Call_Context *cctx,
struct NFast_Transaction_Context *tctx,
@ -50,7 +105,7 @@ int my_bignumreceiveupcall(struct NFast_Application *app,
if ( !pBN ) return NOMEM;
alloc_counter++;
nfutil_copybytes(pBN->bytes, (const unsigned char *)source,
my_util_copybytes(pBN->bytes, (const unsigned char *)source,
nbytes, 0, 0);
pBN->msb_first = msbitfirst;
@ -93,7 +148,7 @@ int my_bignumsendupcall(struct NFast_Application *app,
swapends = (!msbitfirst) ^ (!pBN->msb_first);
swapwords = (!mswordfirst) ^ (!pBN->msw_first);
nfutil_copybytes( (unsigned char *)dest, (*bignum)->bytes, nbytes,
my_util_copybytes( (unsigned char *)dest, (*bignum)->bytes, nbytes,
swapends, swapwords );
return Status_OK;
}