aboutsummaryrefslogtreecommitdiffstats
path: root/libparc/parc/security/command-line
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-01-24 17:52:53 +0100
committerMauro Sardara <msardara@cisco.com>2019-01-24 17:52:53 +0100
commitc07ad72f016930e2aba6471d0e2e9625b935bf9a (patch)
tree03aa7b7c737a7a70321ef25d67c2fbd892cd76db /libparc/parc/security/command-line
parent9fc2b9ec49c54ec2d5f0164bbedc1c78732c464c (diff)
Remove cframework files from master
Change-Id: I02f17ede1cf97986a8b8852ed6d6a28fc016f590 Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libparc/parc/security/command-line')
-rw-r--r--libparc/parc/security/command-line/.gitignore1
-rw-r--r--libparc/parc/security/command-line/CMakeLists.txt8
-rw-r--r--libparc/parc/security/command-line/parc-publickey.c128
-rw-r--r--libparc/parc/security/command-line/parcPublicKey_About.c44
-rwxr-xr-xlibparc/parc/security/command-line/parcPublicKey_About.h54
5 files changed, 0 insertions, 235 deletions
diff --git a/libparc/parc/security/command-line/.gitignore b/libparc/parc/security/command-line/.gitignore
deleted file mode 100644
index 988c6e03..00000000
--- a/libparc/parc/security/command-line/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-parc_publickey
diff --git a/libparc/parc/security/command-line/CMakeLists.txt b/libparc/parc/security/command-line/CMakeLists.txt
deleted file mode 100644
index 27825978..00000000
--- a/libparc/parc/security/command-line/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-set(PARC_PUBLICKEY_SRC
- parc-publickey.c
- parcPublicKey_About.c
- )
-
-add_executable(parc-publickey ${PARC_PUBLICKEY_SRC})
-target_link_libraries(parc-publickey ${PARC_BIN_LIBRARIES})
-install( TARGETS parc-publickey COMPONENT library RUNTIME DESTINATION bin )
diff --git a/libparc/parc/security/command-line/parc-publickey.c b/libparc/parc/security/command-line/parc-publickey.c
deleted file mode 100644
index 6b0caa08..00000000
--- a/libparc/parc/security/command-line/parc-publickey.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2017 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <parc/assert/parc_Assert.h>
-
-#include <parc/algol/parc_ArrayList.h>
-#include <parc/security/parc_Security.h>
-#include <parc/security/parc_Pkcs12KeyStore.h>
-#include <parc/security/parc_PublicKeySigner.h>
-
-void
-parcPublicKey_Create(PARCArrayList *args)
-{
- unsigned int keyLength = 1024;
- unsigned int validityDays = 30;
-
- char *fileName = parcArrayList_Get(args, 2);
- char *password = parcArrayList_Get(args, 3);
- char *subjectName = parcArrayList_Get(args, 4);
- PARCSigningAlgorithm signAlgo = PARCSigningAlgorithm_RSA;
-
- if (parcArrayList_Size(args) > 5) {
- keyLength = (unsigned int) strtoul(parcArrayList_Get(args, 5), NULL, 10);
- }
-
- if (parcArrayList_Size(args) > 6) {
- validityDays = (unsigned int) strtoul(parcArrayList_Get(args, 6), NULL, 10);
- }
-
- bool result = parcPkcs12KeyStore_CreateFile(fileName, password, subjectName, signAlgo, keyLength, validityDays);
- if (!result) {
- printf("Error: %s %s", fileName, strerror(errno));
- return;
- }
- printf("Created %s, key length %d valid for %d days.\n", fileName, keyLength, validityDays);
-}
-
-void
-parcPublicKey_Validate(PARCArrayList *args)
-{
- char *fileName = parcArrayList_Get(args, 2);
- char *password = parcArrayList_Get(args, 3);
-
- PARCPkcs12KeyStore *keyStore = parcPkcs12KeyStore_Open(fileName, password, PARCCryptoHashType_SHA256);
- PARCKeyStore *publicKeyStore = parcKeyStore_Create(keyStore, PARCPkcs12KeyStoreAsKeyStore);
-
- PARCPublicKeySigner *signer = parcPublicKeySigner_Create(publicKeyStore, PARCCryptoSuite_RSA_SHA256);
- PARCSigner *pkSigner = parcSigner_Create(signer, PARCPublicKeySignerAsSigner);
-
- parcKeyStore_Release(&publicKeyStore);
- parcPkcs12KeyStore_Release(&keyStore);
-
- if (pkSigner == NULL) {
- printf("Invalid %s\n", fileName);
- return;
- }
- printf("Valid %s\n", fileName);
-}
-
-void
-printUsage(char *progName)
-{
- printf("usage: %s [-h | --help] [[-c | --create] fileName password subjectName [keyLength validityDays] | [-v | --validate] fileName password]\n", progName);
- printf("\n");
- printf("\n");
- printf("Create and validate PKCS12 keystores that are used with the CCNx code.\n");
- printf("\n");
- printf("optional arguments:\n");
- printf("\t-h, --help\tShow this help message and exit\n");
- printf("\t-c, --create\tCreate a PKCS12 keystore with the given filename, password, subject name, and optional key length and validity length (in days)\n");
- printf("\n");
- printf("\t\t\texample: ./parc_publickey -c keyfile.pkcs12 <password> <subject name> 1024 365\n");
- printf("\n");
- printf("\t-v, --validate\tValidate a PKCS12 file with the given password\n");
- printf("\n");
- printf("\t\t\texample: ./parc_publickey -v keyfile.pkcs12 <password>");
- printf("\n");
-}
-
-int
-main(int argc, char *argv[])
-{
- char *programName = "parc_publickey";
- if (argc < 2) {
- printUsage(programName);
- exit(1);
- }
-
- PARCArrayList *args = parcArrayList_Create(NULL);
- parcArrayList_AddAll(args, (void **) argv, argc);
-
- parcSecurity_Init();
-
- char *arg = parcArrayList_Get(args, 1);
- if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) {
- printUsage(programName);
- return 0;
- } else if (strcmp(arg, "-c") == 0 || strcmp(arg, "--create") == 0) {
- parcPublicKey_Create(args);
- } else if (strcmp(arg, "-v") == 0 || strcmp(arg, "--validate") == 0) {
- parcPublicKey_Validate(args);
- } else {
- printUsage(programName);
- exit(1);
- }
-
- parcSecurity_Fini();
- return 0;
-}
diff --git a/libparc/parc/security/command-line/parcPublicKey_About.c b/libparc/parc/security/command-line/parcPublicKey_About.c
deleted file mode 100644
index c992de22..00000000
--- a/libparc/parc/security/command-line/parcPublicKey_About.c
+++ /dev/null
@@ -1,44 +0,0 @@
-// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
-// generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
-
-#include "parcPublicKey_About.h"
-
-const char *parcPublicKey_What = "@(#)" "PARC public key " RELEASE_VERSION " 2017-02-15T13:31:10.603139"
- "@(#)" "\tCopyright (c) 2017 Cisco and/or its affiliates.";
-
-const char *
-parcPublicKeyAbout_Name(void)
-{
- return "PARC public key";
-}
-
-const char *
-parcPublicKeyAbout_Version(void)
-{
- return RELEASE_VERSION;
-}
-
-const char *
-parcPublicKeyAbout_About(void)
-{
- return "PARC public key "RELEASE_VERSION " 2017-02-15T13:31:10.603139" "\nCopyright (c) 2017 Cisco and/or its affiliates.\n";
-}
-
-const char *
-parcPublicKeyAbout_MiniNotice(void)
-{
- return "Copyright (c) 2017 Cisco and/or its affiliates.\n";
-}
-
-const char *
-parcPublicKeyAbout_ShortNotice(void)
-{
- return "Copyright (c) 2017 Cisco and/or its affiliates.\n";
-}
-
-const char *
-parcPublicKeyAbout_LongNotice(void)
-{
- return "Copyright (c) 2017 Cisco and/or its affiliates.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n";
-}
-
diff --git a/libparc/parc/security/command-line/parcPublicKey_About.h b/libparc/parc/security/command-line/parcPublicKey_About.h
deleted file mode 100755
index fccb7b7d..00000000
--- a/libparc/parc/security/command-line/parcPublicKey_About.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
-// generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
-
-#ifndef parcPublicKey_About_h
-#define parcPublicKey_About_h
-/**
- * Embedded string containing information for the what(1) command.
- *
- */
-extern const char *parcPublicKey_What;
-
-/**
- * Return the name as a C string.
- *
- * @return The name as a C string.
- */
-const char *parcPublicKeyAbout_Name(void);
-
-/**
- * Return the version as a C string.
- *
- * @return The version as a C string.
- */
-const char *parcPublicKeyAbout_Version(void);
-
-/**
- * Return the About text as a C string.
- *
- * @return The About text as a C string.
- */
-const char *parcPublicKeyAbout_About(void);
-
-/**
- * Return the minimum copyright notice as a C string.
- *
- * @return The minimum copyright notice as a C string.
- */
-const char *parcPublicKeyAbout_MiniNotice(void);
-
-/**
- * Return the short copyright notice as a C string.
- *
- * @return The short copyright notice as a C string.
- */
-const char *parcPublicKeyAbout_ShortNotice(void);
-
-/**
- * Return the long copyright notice as a C string.
- *
- * @return The long copyright notice as a C string.
- */
-const char *parcPublicKeyAbout_LongNotice(void);
-
-#endif // parcPublicKey_About_h