| Remote Access Control | |||||
Copyright (c) 2006, Atmel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file createtxhex.cpp.
#include "hexfile.h"
#include <sstream>
#include <iomanip>
#include <string>
#include <stdexcept>
#include <vector>
#include <fstream>
#include <algorithm>
Include dependency graph for createtxhex.cpp:

Go to the source code of this file.
Data Structures | |
| class | ParameterParser |
| Class to parse and store command line parameters for this application. More... | |
Functions | |
| void | CreateHEXFile (const ParameterParser &parser) |
| int | main (size_t argc, const char **argv) |
| void CreateHEXFile | ( | const ParameterParser & | parser | ) |
This function creates a HEX file from parameters stored in a parameter parser object.
Definition at line 233 of file createtxhex.cpp.
References ParameterParser::GetCounterValue(), ParameterParser::GetFilename(), ParameterParser::GetSecretKey(), ParameterParser::GetSerialNo(), and ParameterParser::GetSharedKey().
Referenced by main().
00234 { 00235 HEXFile hexData; 00236 std::ofstream outFile( parser.GetFilename().c_str() ); 00237 00238 // Prepare serial number bytes. 00239 HEXRecord serialNo; 00240 std::vector< byte > serialNoReversed = parser.GetSerialNo(); 00241 std::reverse( serialNoReversed.begin(), serialNoReversed.end() ); 00242 serialNo << serialNoReversed; 00243 00244 // Prepare counter value bytes. 00245 HEXRecord counterValue; 00246 std::vector< byte > counterValueReversed = parser.GetCounterValue(); 00247 std::reverse( counterValueReversed.begin(), counterValueReversed.end() ); 00248 counterValue << counterValueReversed; 00249 00250 // Prepare secret key bytes. 00251 HEXRecord secretKey; 00252 secretKey << parser.GetSecretKey(); 00253 00254 // Prepare shared key bytes. 00255 HEXRecord sharedKey; 00256 sharedKey << parser.GetSharedKey(); 00257 00258 // Add records to HEX file. 00259 hexData << serialNo << counterValue << secretKey << sharedKey; 00260 00261 // Write to disk. 00262 outFile << hexData; 00263 }
Here is the call graph for this function:

| int main | ( | size_t | argc, | |
| const char ** | argv | |||
| ) |
Definition at line 267 of file createtxhex.cpp.
References CreateHEXFile(), ParameterParser::GetCounterSize(), ParameterParser::GetCounterValueString(), ParameterParser::GetFilename(), ParameterParser::GetKeySize(), ParameterParser::GetSecretKeyString(), ParameterParser::GetSerialNoSize(), ParameterParser::GetSerialNoString(), and ParameterParser::GetSharedKeyString().
00268 { 00269 try { 00270 const std::string endian( " (Byte order reversed in HEX file)" ); 00271 ParameterParser parser( argc, argv ); 00272 std::cout << "Filename : " << parser.GetFilename() << std::endl 00273 << "Key size : " << parser.GetKeySize() << std::endl 00274 << "Serial no size: " << parser.GetSerialNoSize() << std::endl 00275 << "Counter size : " << parser.GetCounterSize() << std::endl 00276 << "Shared key : " << parser.GetSharedKeyString() << std::endl 00277 << "Secret key : " << parser.GetSecretKeyString() << std::endl 00278 << "Serial no : " << parser.GetSerialNoString() << endian << std::endl 00279 << "Counter value : " << parser.GetCounterValueString() << endian << std::endl; 00280 00281 CreateHEXFile( parser ); 00282 std::cout << std::endl << parser.GetFilename() << " created!" << std::endl; 00283 00284 } catch( const std::exception & e ) { 00285 std::cout << "Error: " << e.what() << std::endl; 00286 } catch(...) { 00287 std::cout << "Unknown error" << std::endl; 00288 } 00289 }
Here is the call graph for this function:

Generated on Fri Aug 8 11:02:39 2008 for AVR411 Secure Rolling Code Algorithm (PC Tools - createtxhex) by 1.4.7
|