bool PrivateKeyInfoCodec::Import(const std::vector<uint8>& input) { if (input.empty()) { return false; } // Parse the private key info up to the public key values, ignoring // the subsequent private key values. uint8* src = const_cast<uint8*>(&input.front()); uint8* end = src + input.size(); if (!ReadSequence(&src, end) || !ReadVersion(&src, end) || !ReadAlgorithmIdentifier(&src, end) || !ReadTypeHeaderAndLength(&src, end, kOctetStringTag, NULL) || !ReadSequence(&src, end) || !ReadVersion(&src, end) || !ReadInteger(&src, end, &modulus_)) return false; int mod_size = modulus_.size(); if(mod_size % 2 != 0) return false;; int primes_size = mod_size / 2; if (!ReadIntegerWithExpectedSize(&src, end, 4, &public_exponent_) || !ReadIntegerWithExpectedSize(&src, end, mod_size, &private_exponent_) || !ReadIntegerWithExpectedSize(&src, end, primes_size, &prime1_) || !ReadIntegerWithExpectedSize(&src, end, primes_size, &prime2_) || !ReadIntegerWithExpectedSize(&src, end, primes_size, &exponent1_) || !ReadIntegerWithExpectedSize(&src, end, primes_size, &exponent2_) || !ReadIntegerWithExpectedSize(&src, end, primes_size, &coefficient_)) return false; if(src != end) return false; return true; }
/******************************************************************************* * 函数名称: 升级第一步, 进入BOOT 区域, 比对版本号 * 输入参数: * 输出参数: * --返回值: * 函数功能: -- *******************************************************************************/ void IEC62056_21_Process(void) { //uint8_t verstate; MFS_UARTDisableRX(UART52_Ch); MFS_UARTEnableTX(UART52_Ch); //MFS_UARTEnableRX(UART52_Ch); verstate = 0u; verstate = ReadVersion(); switch(verstate) { case METER_TYPE_ERR: BuzzSound(VERSION_ERR); printf("METER_TYPE_ERR \r\n"); break; case VERSION_ERR: BuzzSound(VERSION_ERR); printf("VERSION_ERR \r\n"); break; case VERSION_OK: BuzzSound(VERSION_OK); printf("VERSION_OK \r\n"); Enter21Upgrade(); break; } bFM3_GPIO_PDOR0_PD = 1u; /* LED 201 light off */ bFM3_GPIO_PDOR0_PC = 1u; /* LED 202 light off */ MFS_UARTDisableTX(UART52_Ch); //MFS_UARTDisableRX(UART52_Ch); }
int ReadFileProcess(int *ver_len, unsigned char*pfile_buf, unsigned long *file_len,FILE * fpReadIn ) { LogDisplay("读入文件版本\r\n"); if((*ver_len=ReadVersion(Ver_Buf,Version_File_Name))<0) return -1; #if 0 /*文件DES加密后输出*/ LogDisplay("对升级文件进行加密...\r\n"); if(DES_Encrypt(FileName,keyStr,DESFileName)<0) { sprintf(Print_Buf,"File:\t%s DES Encrypt Failed!\r\n",FileName); LogDisplay(Print_Buf); return -1; } sprintf(Print_Buf,"File: %s DES EncryptSucceed!\r\n",FileName); LogDisplay(Print_Buf); /*加密文件读入并加入CRC校验*/ LogDisplay("加密文件添加CRC校验...\r\n"); #endif LogDisplay("读入升级文件...\r\n"); memset(pfile_buf,0,FLIE_BUFFER_SIZE); /*文件读入并CRC32校验*/ if( File_Crc32( pfile_buf, file_len,fpReadIn,FileName)<0) { return -1; } return 1; }
BOOL DScm::LoadMap(VOID) { if (!m_Chk.Load(CHK_FILE_PATH)) return FALSE; if (!ReadVersion()) return FALSE; if (!ReadEra()) return FALSE; if (!ReadMapSize()) return FALSE; if (!ReadTile()) return FALSE; if (m_Edit) { if (!ReadIsoMap()) return FALSE; } else { if (!ReadThingy()) return FALSE; } if (!Verify()) return FALSE; return TRUE; }
uint32_t ReadVersionDate(ModelReaderPtr const & reader) { MwmVersion version; if (!ReadVersion(FilesContainerR(reader), version)) return 0; return version.GetVersion(); }
uint32_t ReadVersionTimestamp(ModelReaderPtr const & reader) { MwmVersion version; if (!ReadVersion(FilesContainerR(reader), version)) return 0; return version.timestamp; }
PictSelection::PictSelection (Graphic* gs) : (gs) { valid = true; } // PictSelection knows it's the outermost PictSelection because it was // called with a FILE* pointer, so it must read a version number, skip // over its name, read its graphic state and children, and scale // itself back to screen coordinates when it's finished. PictSelection::PictSelection (FILE* stream, State* state) : (nil) { int fd = fileno(stream); istream from(fd); ReadVersion(from); ReadGridSpacing(from); if (versionnumber < 3) { Skip(from); } ReadPictGS(from, state); ReadChildren(from, state); ScaleToScreenCoords(); valid = from.good(); } // Copy returns a copy of the PictSelection. Graphic* PictSelection::Copy () { Selection* copy = new PictSelection(this); for (First(); !AtEnd(); Next()) { copy->Append(GetCurrent()->Copy()); } return copy; } // HasChildren returns true so Idraw can ungroup this Picture. boolean PictSelection::HasChildren () { return Picture::HasChildren(); } // Propagate must preserve the PictSelection's transformation matrix // if it has any. void PictSelection::Propagate () { Transformer* original = GetTransformer(); if (original != nil) { original->Reference(); Selection::Propagate(); SetTransformer(original); delete original; } else { Selection::Propagate(); } }
/** * * @brief Request the version string from the 8261. Used to * prime the serial interface. * * @return bool True on success */ bool Instek8261Serial::PrimeSerialStream(void) { bool status = false; int retry = 0; while (retry < 4) { if (ReadVersion()) { status = true; break; } QThread::msleep(250); retry++; } return status; }
void CBC_DataMatrixBitMatrixParser::Init(CBC_CommonBitMatrix* bitMatrix, int32_t& e) { int32_t dimension = bitMatrix->GetHeight(); if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) { e = BCExceptionFormatException; return; } m_version = ReadVersion(bitMatrix, e); BC_EXCEPTION_CHECK_ReturnVoid(e); m_mappingBitMatrix = ExtractDataRegion(bitMatrix, e); BC_EXCEPTION_CHECK_ReturnVoid(e); m_readMappingMatrix = new CBC_CommonBitMatrix(); m_readMappingMatrix->Init(m_mappingBitMatrix->GetWidth(), m_mappingBitMatrix->GetHeight()); }
void AssertVersion(const std::string &assetroot) { const std::string version = ReadVersion(assetroot); const std::string fusionVer = GEE_VERSION; // NOTE: the exception below should never trigger since we call // gefdaemoncheck before launching the daemons. // This routine is called from the daemons just to be safe. if (version != fusionVer) { throw khException(kh::tr( "This machine is running fusion software version %1.\n" "%2 is configured to use version %3.\n" "Unable to proceed.") .arg(fusionVer) .arg(assetroot) .arg(version)); } }
void BootService(void) { BlinkUSBStatus(); if((usb_device_state < CONFIGURED_STATE)||(UCONbits.SUSPND==1)) return; if(trf_state == SENDING_RESP) { if(!mBootTxIsBusy()) { BOOT_BD_OUT.Cnt = sizeof(dataPacket); mUSBBufferReady(BOOT_BD_OUT); trf_state = WAIT_FOR_CMD; }//end if return; }//end if if(!mBootRxIsBusy()) { counter = 0; switch(dataPacket.CMD) { case READ_VERSION: ReadVersion(); counter=0x04; break; case READ_FLASH: case READ_CONFIG: ReadProgMem(); counter+=0x05; break; case WRITE_FLASH: WriteProgMem(); counter=0x01; break; case ERASE_FLASH: EraseProgMem(); counter=0x01; break; case READ_EEDATA: ReadEE(); counter+=0x05; break; case WRITE_EEDATA: WriteEE(); counter=0x01; break; case WRITE_CONFIG: WriteConfig(); counter=0x01; break; case RESET: //When resetting, make sure to drop the device off the bus //for a period of time. Helps when the device is suspended. UCONbits.USBEN = 0; big_counter = 0; while(--big_counter); Reset(); break; case UPDATE_LED: if(dataPacket.led_num == 3) { mLED_3 = dataPacket.led_status; counter = 0x01; }//end if if(dataPacket.led_num == 4) { mLED_4 = dataPacket.led_status; counter = 0x01; }//end if break; default: break; }//end switch() trf_state = SENDING_RESP; if(counter != 0) { BOOT_BD_IN.Cnt = counter; mUSBBufferReady(BOOT_BD_IN); }//end if }//end if }//end BootService