Esempio n. 1
0
int SignatureSave(SECURITY_INFO *pBufferAddr)
{   
   int ret=-1;
   int ret_bk =-1;
   unsigned int u32SigOffset = 0;  
   unsigned int u32SigBkOffset = 0; 
   unsigned int u32SecuritySize= 0;
   UBOOT_TRACE("IN\n");
   
   //Here, we check the CRC of SECUREITY_INFO, and the check range is from "pBufferAddr->data" to "pBufferAddr->data_interleave"
   u32SecuritySize = sizeof(_SECURITY_INFO_DATA) * NUMBER_OF_SECURE_INFO;

   if(pBufferAddr==NULL)
   {
      UBOOT_ERROR("The input parameter pBufferAddr' is a null pointer\n");
      return -1;
   }

   ret = raw_io_config(FLASH_DEFAULT_TARGET,FLASH_DEFAULT_PARTITION,FLASH_DEFAULT_VOLUME);
   if(ret != 0)
   {
       UBOOT_ERROR("raw_io_config setting fail!\n");
       return -1;
   }

   ret = get_signature_offset(&u32SigOffset,&u32SigBkOffset);
   if(ret != 0)
   {
       UBOOT_ERROR("get_signature_offset fail!\n");
       return -1;
   }

   UBOOT_DEBUG("u32SigOffset : 0x%x\n",u32SigOffset);
   UBOOT_DEBUG("u32SigBkOffset : 0x%x\n",u32SigBkOffset);

   // update CRC
   pBufferAddr->crc = crc32(0, (unsigned char const *)&pBufferAddr->data,u32SecuritySize);
   ret = raw_write((unsigned int)pBufferAddr,u32SigOffset,sizeof(SECURITY_INFO));
   ret_bk = raw_write((unsigned int)pBufferAddr,u32SigBkOffset,sizeof(SECURITY_INFO));

   if(EN_SUCCESS == ret || EN_SUCCESS == ret_bk)
   {
       UBOOT_DEBUG("ret : %d , ret_bk : %d \n",ret,ret_bk);
       UBOOT_TRACE("OK\n");
       ret = 0;       
   }
   else
   {
       ret= -1;
       UBOOT_ERROR("SignatureSave fail\n");
   }

    return ret;
}
Esempio n. 2
0
static void
sio_flush_buffer (struct siobuf *sio)
{
  int length;

  assert (sio != NULL);

  if (sio->flush_mark != NULL && sio->flush_mark > sio->write_buffer)
    length = sio->flush_mark - sio->write_buffer;
  else
    length = sio->write_position - sio->write_buffer;
  if (length <= 0)
    return;

  if (sio->monitor_cb != NULL)
    (*sio->monitor_cb) (sio->write_buffer, length, 1, sio->cbarg);

  if (sio->encode_cb != NULL)
    {
      char *buf;
      int len = 0;

      /* Rules for the encode callback.

         The output variables (here buf and len) may be set to the
         write_buffer iff the encoding can be performed in place and
         the result is shorter than the original data.  Otherwise the
         callback must maintain its own buffer which must persist until
         the next call in the same thread.  The secarg argument may be
         used to maintain this buffer. */
      while ((*sio->encode_cb) (&buf, &len, sio->write_buffer, 
                                length, sio->secarg) >0) {
        raw_write (sio, buf, len);
      }
    }
  else
    raw_write (sio, sio->write_buffer, length);

  if (sio->flush_mark != NULL && sio->flush_mark > sio->write_buffer)
    {
      length = sio->write_position - sio->flush_mark;
      if (length > 0)
        memmove (sio->write_buffer, sio->flush_mark, length);
    }
  else
    length = 0;
  sio->write_available = sio->buffer_size - length;
  sio->write_position = sio->write_buffer + length;
  sio->flush_mark = NULL;
}
Esempio n. 3
0
int mdio_read(int phyadr, int reg)
{
	int r;
	
	CSR_MINIMAC_MDIO = MINIMAC_MDIO_OE;
	raw_write(0xffffffff, 32); /* < sync */
	raw_write(0x06, 4); /* < start + read */
	raw_write(phyadr, 5);
	raw_write(reg, 5);
	raw_turnaround();
	r = raw_read();
	raw_turnaround();
	
	return r;
}
Esempio n. 4
0
void CTcpSocketBase::write(void *pcmd , unsigned int len) {
	char cmdbuffer[stBaseMessage::_MAX_MSG_SIZE];
	PTR_CMD(stBaseMessage,cmd,cmdbuffer);
	cmd->size = len;
	memcpy(cmd->body(),pcmd,len);
	raw_write(cmd->head(),cmd->alllen());
}
/* Set the high bit pins high/low */
int set_bits_high(struct mpsse_context *mpsse, int port)
{
	char buf[CMD_SIZE] = { 0 };

	buf[0] = SET_BITS_HIGH;
	buf[1] = port;
	buf[2] = mpsse->trish;

	return raw_write(mpsse, (unsigned char *)&buf, sizeof(buf));
}
Esempio n. 6
0
std::ostream& OggPage::write(std::ostream& to) const
{
	raw_write(to, capture_pattern);
	raw_write(to, version);
	raw_write(to, header_type);
	raw_write(to, absolute_granule_position);
	raw_write(to, stream_serial_number);
	raw_write(to, page_sequence_no);
	raw_write(to, page_checksum);
	raw_write(to, page_segments);
	to.write(reinterpret_cast<const char*>(segment_table.data()), segment_table.size());
	to.write(reinterpret_cast<const char*>(body.data()), body.size());
	return to;
}
Esempio n. 7
0
void mdio_write(int phyadr, int reg, int val)
{
	CSR_MINIMAC_MDIO = MINIMAC_MDIO_OE;
	raw_write(0xffffffff, 32); /* < sync */
	raw_write(0x05, 4); /* < start + write */
	raw_write(phyadr, 5);
	raw_write(reg, 5);
	raw_write(0x02, 2); /* < turnaround */
	raw_write(val, 16);
	raw_turnaround();
}
Esempio n. 8
0
/*
 * []----
 * | raw_write_cmplt -- deal with end game of write
 * |
 * | See if all of the data for this write operation has been dealt
 * | with. If so, send a final acknowledgement back to the transport.
 * | If not, update the offset, calculate the next transfer size, and
 * | start the process again.
 * []---
 */
static void
raw_write_cmplt(emul_handle_t e)
{
	raw_io_t	*io	= (raw_io_t *)e;
	t10_cmd_t	*cmd	= io->r_cmd;

	if ((io->r_offset + io->r_data_len) < (io->r_lba_cnt * 512)) {
		free(io->r_data);

		io->r_offset	+= io->r_data_len;
		io->r_data_len	= MIN(cmd->c_lu->l_targ->s_maxout,
		    (io->r_lba_cnt * 512) - io->r_offset);
		raw_write(cmd, cmd->c_cdb, cmd->c_cdb_len);
		return;
	}
	trans_send_complete(cmd, STATUS_GOOD);
}
Esempio n. 9
0
static inline void zsendline_s(const char *s, size_t count)
{
    const char *end = s + count;

    while (s != end) {
        int last_esc = 0;
        const char *t = s;

        while (t != end) {
            last_esc = zsendline_tab[(unsigned) ((*t) & 0377)];
            if (last_esc)
                break;
            t++;
        }
        if (t != s) {
            raw_write(0, s, (t - s));
            lastsent = t[-1];
            s = t;
        }
        if (last_esc) {
            int c = *s;

            switch (last_esc) {
            case 0:
                xsendline(lastsent = c);
                break;
            case 1:
                xsendline(ZDLE);
                c ^= 0100;
                xsendline(lastsent = c);
                break;
            case 2:
                if ((lastsent & 0177) != '@') {
                    xsendline(lastsent = c);
                } else {
                    xsendline(ZDLE);
                    c ^= 0100;
                    xsendline(lastsent = c);
                }
                break;
            }
            s++;
        }
    }
}
Esempio n. 10
0
PRIVATE OSErr
flush_buffer (our_file_info_t *ofitp)
{
  OSErr retval;
  LONGINT n_to_write;

  n_to_write = length;

  retval = raw_write (ofitp, &n_to_write, (char *) track_bufp);
  if (retval == noErr && n_to_write != length)
    retval = ioErr;
  else
    {
      length = 0;
      offset += n_to_write;
    }
  return retval;
}
Esempio n. 11
0
size_t data_message::write_contact(void* buf, size_t buf_len, session_number_type session_number, sequence_number_type _sequence_number, const contact_map_type& contact_map, const void* seal_key, size_t seal_key_len, const void* enc_key, size_t enc_key_len)
{
    std::vector<uint8_t> cleartext;
    cleartext.resize(contact_map.size() * 49);

    std::vector<uint8_t>::iterator ptr = cleartext.begin();

    for (contact_map_type::const_iterator it = contact_map.begin(); it != contact_map.end(); ++it)
    {
        // We copy the hash
        ptr = std::copy(it->first.begin(), it->first.end(), ptr);

        if (it->second.address().is_v4())
        {
            *(ptr++) = static_cast<uint8_t>(ENDPOINT_TYPE_IPV4);

            boost::asio::ip::address_v4::bytes_type bytes = it->second.address().to_v4().to_bytes();

            ptr = std::copy(bytes.begin(), bytes.end(), ptr);

            *(reinterpret_cast<uint16_t*>(&*ptr)) = htons(it->second.port());

            ptr += sizeof(uint16_t);
        }
        else if (it->second.address().is_v6())
        {
            *(ptr++) = static_cast<uint8_t>(ENDPOINT_TYPE_IPV6);

            boost::asio::ip::address_v6::bytes_type bytes = it->second.address().to_v6().to_bytes();

            ptr = std::copy(bytes.begin(), bytes.end(), ptr);

            *(reinterpret_cast<uint16_t*>(&*ptr)) = htons(it->second.port());

            ptr += sizeof(uint16_t);
        }
    }

    cleartext.resize(std::distance(cleartext.begin(), ptr));

    return raw_write(buf, buf_len, session_number, _sequence_number, &cleartext[0], cleartext.size(), seal_key, seal_key_len, enc_key, enc_key_len, MESSAGE_TYPE_CONTACT);
}
Esempio n. 12
0
/* Send ZMODEM HEX header hdr of type type */
void zshhdr(int type, char *hdr)
{
    register int n;
    register unsigned short crc;
    char s[30];
    size_t len;

    s[0] = ZPAD;
    s[1] = ZPAD;
    s[2] = ZDLE;
    s[3] = ZHEX;
    zputhex(type & 0x7f, s + 4);
    len = 6;
    Crc32t = 0;

    crc = updcrc((type & 0x7f), 0);
    for (n = 4; --n >= 0; ++hdr) {
        zputhex(*hdr, s + len);
        len += 2;
        crc = updcrc((0377 & *hdr), crc);
    }
    crc = updcrc(0, updcrc(0, crc));
    zputhex(crc >> 8, s + len);
    zputhex(crc, s + len + 2);
    len += 4;

    /* Make it printable on remote machine */
    s[len++] = 015;
    s[len++] = 0212;
    /*
     * Uncork the remote in case a fake XOFF has stopped data flow
     */
    if (type != ZFIN && type != ZACK) {
        s[len++] = 021;
    }
    flushmo();
    raw_write(0, s, len);
}
Esempio n. 13
0
void
sio_flush (struct siobuf *sio)
{
  sio_flush_buffer (sio);
  if (sio->encode_cb != NULL)
    {
      char *buf;
      int len = 0;

      /* Rules for the encode callback.

         The output variables (here buf and len) may be set to the
         write_buffer iff the encoding can be performed in place and
         the result is shorter than the original data.  Otherwise the
         callback must maintain its own buffer which must persist until
         the next call in the same thread.  The secarg argument may be
         used to maintain this buffer. */
      while ((*sio->encode_cb) (&buf, &len, sio->write_buffer, 
                                0, sio->secarg) >0) {
        raw_write (sio, buf, len);
      }
    }
}
Esempio n. 14
0
int bbs_zsendfile(char *filename, char *remote)
{
    struct stat f;

    if (stat(filename, &f) != 0)
        return ERROR;
    Totalleft = f.st_size;
    Filesleft = 1;
    calc_blklen(Totalleft);
    protocol = ZM_ZMODEM;
    io_mode_fd = 1;
    blklen = start_blklen = 1024;
    if (setjmp(zmodemjmp) == 0) {
        zsendline_init();
        io_mode(io_mode_fd, 1);
        readline_setup(io_mode_fd, 128, 256);
        raw_write(0, "rz\r", 3);

        /*   TODO : throw away received input */

        purgeline(io_mode_fd);
        stohdr(0L);
        zshhdr(ZRQINIT, Txhdr);
        zrqinits_sent++;
        oflush();

        Crcflg = FALSE;
        firstsec = TRUE;
        bytcnt = (size_t) - 1;
        Totsecs = 0;

        if (wcs(filename, remote) == ERROR) {
            readline_clean();
            return ERROR;
        }
        if (zmodem_requested)
            saybibi();
        else if (protocol != ZM_XMODEM) {
            struct zm_fileinfo zi;
            char *pa;

            pa = (char *)malloc(PATH_MAX + 1);
            *pa = '\0';
            zi.fname = pa;
            zi.modtime = 0;
            zi.mode = 0;
            zi.bytes_total = 0;
            zi.bytes_sent = 0;
            zi.bytes_received = 0;
            zi.bytes_skipped = 0;
            wctxpn(&zi);
            free(pa);
        }

        oflush();
        /* here needs a oflush */
        /* eat avalible input */
        /* better to eat some input here */
        io_mode(io_mode_fd, 0);
        readline_clean();
    } else {
        oflush();
        signal(SIGALRM, SIG_IGN);
        alarm(0);
        return ERROR;
    }
    return OK;
}
Esempio n. 15
0
static void dispatch_out(void) {
    //  update latest serial received
    if (out_packet_ptr) {
        in_packet[0] = out_packet[0];
        if (in_packet_ptr == 0) {
            in_packet_ptr = 1;
        }
    }
    unsigned char ptr = 1;
    while (ptr < out_packet_ptr) {
        unsigned char code = out_packet[ptr];
        ++ptr;
        unsigned char sz = code & 0xf;
        if (sz == 15) {
            if (ptr == out_packet_ptr) {
                goto too_big;
            }
            sz = out_packet[ptr];
            ++ptr;
        }
        if (ptr + sz > out_packet_ptr || ptr + sz < ptr) {
too_big:
            MY_Failure("Too big recv", ptr + sz, out_packet_ptr);
        }
        unsigned char code_ix = (code & 0xf0) >> 4;
        if (code_ix >= sizeof(min_size)) {
unknown_op:
            MY_Failure("Unknown op", code & 0xf0, sz);
        }
        unsigned char msz = 0;
        memcpy_P(&msz, &min_size[code_ix], 1);
        if (sz < msz) {
            MY_Failure("Too small data", sz, code);
        }
        unsigned char *base = &out_packet[ptr];
        switch (code & 0xf0) {
        case OpSetStatus:
            set_status(base[0], sz-1, base+1);
            break;
        case OpGetStatus:
            get_status(base[0]);
            break;
        case OpWriteServo:
            write_servo(base[0], base[1], sz-2, base+2);
            break;
        case OpReadServo:
            read_servo(base[0], base[1], base[2]);
            break; 
        case OpOutText:
            out_text(sz, base);
            break;
        case OpRawWrite:
            raw_write(sz, base);
            break;
        case OpRawRead:
            raw_read(base[0]);
            break;
        default:
            goto unknown_op;
        }
        ptr += sz;
    }
}
Esempio n. 16
0
int
main(int ac, char **av)
{
    char *sf, *af;
    char buf[BSIZE_SP];
    char t, f;
    struct plot *pl;
    size_t n;
    char *infile = NULL;
    char *outfile = NULL;
    FILE *fp;
    cp_in = stdin;
    cp_out = stdout;
    cp_err = stderr;
    cp_curin = stdin;
    cp_curout = stdout;
    cp_curerr = stderr;

    switch (ac) {
        case 5: 
            sf = av[2];
            af = av[4];
            f = *av[1];
            t = *av[3];
            break;

        case 3:
            f = *av[1];
            t = *av[2];
            /* This is a pain, but there is no choice */
            sf = infile = smktemp("scin");
            af = outfile = smktemp("scout");
            if (!(fp = fopen(infile, "w"))) {
                perror(infile);
                exit(EXIT_BAD);
            }
            while ((n = fread(buf, 1, sizeof(buf), stdin)) != 0)
                (void) fwrite(buf, 1, n, fp);
            (void) fclose(fp);
            break;

        case 1: printf("Input file: ");
            (void) fflush(stdout);
            (void) fgets(buf, BSIZE_SP, stdin);
            sf = copy(buf);
            printf("Input type: ");
            (void) fflush(stdout);
            (void) fgets(buf, BSIZE_SP, stdin);
            f = buf[0];
            printf("Output file: ");
            (void) fflush(stdout);
            (void) fgets(buf, BSIZE_SP, stdin);
            af = copy(buf);
            printf("Output type: ");
            (void) fflush(stdout);
            (void) fgets(buf, BSIZE_SP, stdin);
            t = buf[0];
            break;
        default:
            fprintf(cp_err, 
                "Usage: %s fromtype fromfile totype tofile,\n",
                cp_program);
            fprintf(cp_err, "\twhere types are o, b, or a\n");
            fprintf(cp_err, 
                "\tor, %s fromtype totype, used as a filter.\n",
                cp_program);
            exit(EXIT_BAD);
    }
    switch(f) {
        case 'o' :
        pl = oldread(sf);
        break;

        case 'b' :
        case 'a' :
        pl = raw_read(sf);
        break;

        default:
        fprintf(cp_err, "Types are o, a, or b\n");
        exit(EXIT_BAD);
    }
    if (!pl)
        exit(EXIT_BAD);

    switch(t) {
        case 'o' :
        oldwrite(af, FALSE, pl);
        break;

        case 'b' :
        raw_write(af, pl, FALSE, TRUE);
        break;

        case 'a' :
        raw_write(af, pl, FALSE, FALSE);
        break;

        default:
        fprintf(cp_err, "Types are o, a, or b\n");
        exit(EXIT_BAD);
    }
    if (ac == 3) {
        /* Gotta finish this stuff up */
        if (!(fp = fopen(outfile, "r"))) {
            perror(outfile);
            exit(EXIT_BAD);
        }
        while ((n = fread(buf, 1, sizeof(buf), fp)) != 0)
            (void) fwrite(buf, 1, n, stdout);
        (void) fclose(fp);
        (void) unlink(infile);
        (void) unlink(outfile);
    }
    exit(EXIT_NORMAL);
}
Esempio n. 17
0
size_t data_message::write_contact_request(void* buf, size_t buf_len, session_number_type session_number, sequence_number_type sequence_number, const hash_list_type& hash_list, const void* seal_key, size_t seal_key_len, const void* enc_key, size_t enc_key_len)
{
    return raw_write(buf, buf_len, session_number, sequence_number, reinterpret_cast<const char*>(&hash_list[0]), hash_list.size() * hash_type::static_size, seal_key, seal_key_len, enc_key, enc_key_len, MESSAGE_TYPE_CONTACT_REQUEST);
}
Esempio n. 18
0
size_t data_message::write_keep_alive(void* buf, size_t buf_len, session_number_type _session_number, sequence_number_type _sequence_number, size_t random_len, const void* seal_key, size_t seal_key_len, const void* enc_key, size_t enc_key_len)
{
    const cryptoplus::buffer random = cryptoplus::random::get_random_bytes(random_len);

    return raw_write(buf, buf_len, _session_number, _sequence_number, cryptoplus::buffer_cast<uint8_t>(random), cryptoplus::buffer_size(random), seal_key, seal_key_len, enc_key, enc_key_len, MESSAGE_TYPE_KEEP_ALIVE);
}
Esempio n. 19
0
size_t data_message::write(void* buf, size_t buf_len, channel_number_type channel_number, session_number_type _session_number, sequence_number_type _sequence_number, const void* _cleartext, size_t cleartext_len, const void* seal_key, size_t seal_key_len, const void* enc_key, size_t enc_key_len)
{
    return raw_write(buf, buf_len, _session_number, _sequence_number, _cleartext, cleartext_len, seal_key, seal_key_len, enc_key, enc_key_len, to_data_message_type(channel_number));
}
Esempio n. 20
0
File: ctc.c Progetto: dcobas/coht
int vmeio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
		unsigned long arg)
{
	void *arb;		/* Argument buffer area */

	struct vmeio_device *dev;

	int iodr;		/* Io Direction */
	int iosz;		/* Io Size in bytes */
	int cc = 0;		/* erro return code */

	long minor;

	iodr = _IOC_DIR(cmd);
	iosz = _IOC_SIZE(cmd);

	minor = MINOR(inode->i_rdev);
	if (!minor_ok(minor))
		return -EACCES;
	dev = filp->private_data;

	if ((arb = kmalloc(iosz, GFP_KERNEL)) == NULL)
		return -ENOMEM;

	if ((iodr & _IOC_WRITE) && copy_from_user(arb, (void *)arg, iosz)) {
		cc = -EACCES;
		goto out;
	}
	debug_ioctl(_IOC_NR(cmd), iodr, iosz, arb, minor, dev->debug);

	if (!dev) {
		cc = -EACCES;
		goto out;
	}

	switch (cmd) {

	case VMEIO_SET_DEBUG:
		vmeio_set_debug(dev, arb);
		break;

	case VMEIO_GET_DEBUG:
		vmeio_get_debug(dev, arb);
		break;

	case VMEIO_GET_VERSION:
		vmeio_get_version(arb);
		break;

	case VMEIO_SET_TIMEOUT:
		vmeio_set_timeout(dev, arb);
		break;

	case VMEIO_GET_TIMEOUT:
		vmeio_get_timeout(dev, arb);
		break;

	case VMEIO_RAW_READ_DMA:
		cc = raw_dma(dev, arb, VME_DMA_FROM_DEVICE);
		if (cc < 0)
			goto out;
		break;

	case VMEIO_RAW_WRITE_DMA:
		cc = raw_dma(dev, arb, VME_DMA_TO_DEVICE);
		if (cc < 0)
			goto out;
		break;

	case VMEIO_READ_DMA:
	case VMEIO_WRITE_DMA:
		cc = do_raw_dma(arb);
		if (cc < 0)
			goto out;
		break;

	case VMEIO_RAW_READ:
		cc = raw_read(dev, arb);
		if (cc < 0)
			goto out;
		break;

	case VMEIO_RAW_WRITE:
		cc = raw_write(dev, arb);
		if (cc < 0)
			goto out;
		break;

	case VMEIO_GET_MAPPING:
		cc = get_mapping(dev, arb);
		if (cc < 0)
			goto out;
		break;

#ifdef ENCORE_DAL
	case VMEIO_GET_NREGS:
		get_nregs(arb);
		break;
	case VMEIO_GET_REGINFO:
		cc = get_reginfo(arb);
		break;
#else
	case VMEIO_GET_NREGS:
	case VMEIO_GET_REGINFO:
		cc = -ENOENT;
		break;
#endif

	default:
		cc = -ENOENT;
		goto out;
		break;
	}

	if ((iodr & _IOC_READ) && copy_to_user((void *)arg, arb, iosz)) {
			cc = -EACCES;
			goto out;
	}
out:	kfree(arb);
	return cc;
}
Esempio n. 21
0
File: newio.c Progetto: zhouqt/kbs
void raw_ochar(char c)
{
    raw_write(0, &c, 1);
}
Esempio n. 22
0
int SignatureLoad(SECURITY_INFO *pBufferAddr)
{
    int ret = -1;
    int flag1=0, flag2=0;    
    unsigned int u32SigOffset = 0;
    unsigned int u32SigBkOffset = 0;     
    unsigned int u32SecuritySize= 0;
    UBOOT_TRACE("IN\n");

    //Here, we check the CRC of SECUREITY_INFO, and the check range include "pBufferAddr->data" and "pBufferAddr->data_interleave"
    u32SecuritySize = sizeof(_SECURITY_INFO_DATA) * NUMBER_OF_SECURE_INFO;

    if(pBufferAddr==NULL)
    {
        UBOOT_ERROR("The input parameter pBufferAddr' is a null pointer\n");
        return -1;
    }

    ret = raw_io_config(FLASH_DEFAULT_TARGET,FLASH_DEFAULT_PARTITION,FLASH_DEFAULT_VOLUME);
    if(ret != 0)
    {
        UBOOT_ERROR("raw_io_config setting fail!\n");
        return -1;
    }

    ret = get_signature_offset(&u32SigOffset,&u32SigBkOffset);
    if(ret != 0)
    {
        UBOOT_ERROR("get_signature_offset fail!\n");
        return -1;
    }
   
    ret = raw_read((unsigned int)pBufferAddr,u32SigOffset,sizeof(SECURITY_INFO));
    
    if( (EN_SUCCESS == ret) && (pBufferAddr->crc == crc32(0, (unsigned char const *)&pBufferAddr->data,u32SecuritySize)) )
        flag1=1;
    
    ret = raw_read((unsigned int)pBufferAddr,u32SigBkOffset,sizeof(SECURITY_INFO));
    
    if( (EN_SUCCESS == ret) && (pBufferAddr->crc == crc32(0, (unsigned char const *)&pBufferAddr->data,u32SecuritySize)) )
        flag2=1;

    if( (flag2==0) && (flag1!=0) )
    {
        ret = raw_read((unsigned int)pBufferAddr,u32SigOffset,sizeof(SECURITY_INFO));
        if( (EN_SUCCESS == ret) && (pBufferAddr->crc == crc32(0, (unsigned char const *)&pBufferAddr->data,u32SecuritySize)))
        {
            ret = raw_write((unsigned int)pBufferAddr,u32SigBkOffset,sizeof(SECURITY_INFO));
        }
        else
        {
            UBOOT_ERROR("raw_read fail or caculate crc fail!\n");
            return -1;
        }
    }

    if((flag1==0)&&(flag2!=0))
    {
        ret = raw_write((unsigned int)pBufferAddr,u32SigOffset,sizeof(SECURITY_INFO));
    }

   if(EN_SUCCESS == ret)
   {
       ret=0;
       UBOOT_TRACE("OK\n");
   }
   else
   {
       ret=-1;
       UBOOT_ERROR("SignatureLoad fail\n");
   }

   return ret;
}