diff options
author | Ade Lee <alee@redhat.com> | 2012-08-15 14:10:08 -0400 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2012-08-15 14:10:08 -0400 |
commit | 3b1ca60d799ca02305b8a2c61eb279f74787cff0 (patch) | |
tree | d1ec49f3d77cb77fc6043580b23c371508fea802 /base/tps/src | |
parent | 87b5eaa5b1409bc362867e3849fe16c8f205afa9 (diff) | |
parent | 75e1c66acb48e67951fc0ce5680328773fe837ae (diff) | |
download | pki-3b1ca60d799ca02305b8a2c61eb279f74787cff0.tar.gz pki-3b1ca60d799ca02305b8a2c61eb279f74787cff0.tar.xz pki-3b1ca60d799ca02305b8a2c61eb279f74787cff0.zip |
Merge branch 'my_tpsclient'
Diffstat (limited to 'base/tps/src')
-rw-r--r-- | base/tps/src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | base/tps/src/apdu/Generate_Key_ECC_APDU.cpp | 62 | ||||
-rw-r--r-- | base/tps/src/include/apdu/APDU.h | 3 | ||||
-rw-r--r-- | base/tps/src/include/apdu/Generate_Key_ECC_APDU.h | 60 |
4 files changed, 125 insertions, 1 deletions
diff --git a/base/tps/src/CMakeLists.txt b/base/tps/src/CMakeLists.txt index 5f588663c..b0276f8e2 100644 --- a/base/tps/src/CMakeLists.txt +++ b/base/tps/src/CMakeLists.txt @@ -79,6 +79,7 @@ set(tps_library_SRCS apdu/Get_Data_APDU.cpp apdu/External_Authenticate_APDU.cpp apdu/Generate_Key_APDU.cpp + apdu/Generate_Key_ECC_APDU.cpp apdu/Read_Buffer_APDU.cpp apdu/Read_Object_APDU.cpp apdu/Write_Object_APDU.cpp diff --git a/base/tps/src/apdu/Generate_Key_ECC_APDU.cpp b/base/tps/src/apdu/Generate_Key_ECC_APDU.cpp new file mode 100644 index 000000000..0e6069a00 --- /dev/null +++ b/base/tps/src/apdu/Generate_Key_ECC_APDU.cpp @@ -0,0 +1,62 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, +// Boston, MA 02110-1301 USA +// +// Copyright (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +#include <stdio.h> +#include "apdu/APDU.h" +#include "apdu/Generate_Key_ECC_APDU.h" +#include "main/Memory.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +/** + * Constructs Generate Key ECC APDU. + */ +TPS_PUBLIC Generate_Key_ECC_APDU::Generate_Key_ECC_APDU (BYTE p1, BYTE p2, BYTE alg, int keysize, BYTE option, +BYTE type, Buffer &wrapped_challenge, Buffer &key_check) +{ + SetCLA(0x84); + SetINS(0x0D); + SetP1(p1); + SetP2(p2); + + Buffer data1; + + data1 = Buffer(1,alg) + Buffer(1,(BYTE)(keysize/256)) + Buffer(1,(BYTE)(keysize%256)) + Buffer(1,option) + Buffer(1,type) + Buffer(1,(BYTE)wrapped_challenge.size()) + Buffer(wrapped_challenge) + Buffer(1,(BYTE)key_check.size()); + + if(key_check.size() > 0) { + data1 = data1 + Buffer(key_check); + } + + SetData(data1); + +} + +TPS_PUBLIC Generate_Key_ECC_APDU::~Generate_Key_ECC_APDU () +{ +} + +TPS_PUBLIC APDU_Type Generate_Key_ECC_APDU::GetType() +{ + return APDU_GENERATE_KEY_ECC; +} diff --git a/base/tps/src/include/apdu/APDU.h b/base/tps/src/include/apdu/APDU.h index e0f778a19..cfb66ad19 100644 --- a/base/tps/src/include/apdu/APDU.h +++ b/base/tps/src/include/apdu/APDU.h @@ -75,7 +75,8 @@ enum APDU_Type { APDU_IMPORT_KEY = 24, APDU_IMPORT_KEY_ENC = 25, APDU_SET_ISSUERINFO = 26, - APDU_GET_ISSUERINFO = 27 + APDU_GET_ISSUERINFO = 27, + APDU_GENERATE_KEY_ECC = 28 }; class APDU diff --git a/base/tps/src/include/apdu/Generate_Key_ECC_APDU.h b/base/tps/src/include/apdu/Generate_Key_ECC_APDU.h new file mode 100644 index 000000000..c1a4e3764 --- /dev/null +++ b/base/tps/src/include/apdu/Generate_Key_ECC_APDU.h @@ -0,0 +1,60 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef GENERATE_KEY_ECC_APDU_H +#define GENERATE_KEY_ECC_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Generate_Key_ECC_APDU : public APDU +{ + public: + TPS_PUBLIC Generate_Key_ECC_APDU (BYTE p1, BYTE p2, BYTE alg, + int keysize, BYTE option, + BYTE type, Buffer &wrapped_challenge, Buffer &key_check); + TPS_PUBLIC ~Generate_Key_ECC_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* GENERATE_KEY_ECC_APDU_H */ |