Remove unused key-manager-util.*
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 26 Jan 2015 13:28:26 +0000 (14:28 +0100)
committerMaciej J. Karpiuk <m.karpiuk2@samsung.com>
Tue, 17 Feb 2015 11:09:37 +0000 (12:09 +0100)
[Issue#] N/A
[Feature/Bug] N/A
[Problem] N/A
[Cause] Unused files
[Solution] Removed

[Verification] Successfull compilation

Change-Id: Ie71d5fd9b8093f262643efe5ad7930ea0d5ff53e

src/CMakeLists.txt
src/manager/main/key-manager-util.cpp [deleted file]
src/manager/main/key-manager-util.h [deleted file]
src/manager/service/CryptoService.cpp
src/manager/service/ocsp.cpp

index b3bfc10..d198f18 100644 (file)
@@ -15,7 +15,6 @@ SET(KEY_MANAGER_SRC_PATH ${PROJECT_SOURCE_DIR}/src)
 SET(KEY_MANAGER_PATH ${PROJECT_SOURCE_DIR}/src/manager)
 
 SET(KEY_MANAGER_SOURCES
-    ${KEY_MANAGER_PATH}/main/key-manager-util.cpp
     ${KEY_MANAGER_PATH}/main/generic-socket-manager.cpp
     ${KEY_MANAGER_PATH}/main/socket-manager.cpp
     ${KEY_MANAGER_PATH}/main/key-manager-main.cpp
diff --git a/src/manager/main/key-manager-util.cpp b/src/manager/main/key-manager-util.cpp
deleted file mode 100644 (file)
index 04f424d..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- *  ckm-manager
- *
- *  Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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
- *
- *      ://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 <stdio.h>
-#include <stdlib.h>
-#include <sys/smack.h>
-#include <unistd.h>
-#include <fts.h>
-#include <openssl/pem.h>
-#include <openssl/bio.h>
-
-#include <limits>
-
-#include <key-manager-util.h>
-#include <dpl/log/log.h>
-
-
-
-namespace {
-const size_t SIZE_T_MAX = std::numeric_limits<size_t>::max();
-} // namespace anonymous
-
-namespace CKM {
-
-int util_smack_label_is_valid(const char *smack_label)
-{
-    int i;
-
-    if (!smack_label || smack_label[0] == '\0' || smack_label[0] == '-')
-        goto err;
-
-    for (i = 0; smack_label[i]; ++i) {
-        if (i >= SMACK_LABEL_LEN)
-            return 0;
-        switch (smack_label[i]) {
-            case '~':
-            case ' ':
-            case '/':
-            case '"':
-            case '\\':
-            case '\'':
-                goto err;
-            default:
-                break;
-        }
-    }
-
-    return 1;
-err:
-    LogError("Invalid Smack label: " << (smack_label ? smack_label : ""));
-    return 0;
-}
-
-char *read_exe_path_from_proc(pid_t pid)
-{
-    char link[32];
-    char *exe = NULL;
-    size_t size = 64;
-    ssize_t cnt = 0;
-
-    // get link to executable
-    snprintf(link, sizeof(link), "/proc/%d/exe", pid);
-
-    for (;;)
-    {
-        exe = (char*) malloc(size);
-        if (exe == NULL)
-        {
-            LogError("Out of memory");
-            return NULL;
-        }
-
-        // read link target
-        cnt = readlink(link, exe, size);
-
-        // error
-        if (cnt < 0 || (size_t) cnt > size)
-        {
-            LogError("Can't locate process binary for pid=" << pid);
-            free(exe);
-            return NULL;
-        }
-
-        // read less than requested
-        if ((size_t) cnt < size)
-            break;
-
-        // read exactly the number of bytes requested
-        free(exe);
-        if (size > (SIZE_T_MAX >> 1))
-        {
-            LogError("Exe path too long (more than " << size << " characters)");
-            return NULL;
-        }
-        size <<= 1;
-    }
-    // readlink does not append null byte to buffer.
-    exe[cnt] = '\0';
-    return exe;
-}
-
-void rawBufferToX509(X509 **ppCert, RawBuffer rawCert) {
-  BIO *bio = BIO_new(BIO_s_mem());
-  BIO_write(bio, rawCert.data(), rawCert.size());
-  d2i_X509_bio(bio, ppCert);
-  BIO_free_all(bio);
-}
-
-void x509ToRawBuffer(RawBuffer &buf, X509 *cert) {
-  int len = i2d_X509(cert, NULL);
-  unsigned char tmpBuff[len];
-  unsigned char *p = tmpBuff;
-  i2d_X509(cert, &p);
-  buf.assign(tmpBuff, tmpBuff +len);
-}
-
-STACK_OF(X509) *loadSystemCerts( const char * dirpath) {
-    FTS *fts = NULL;
-    FTSENT *ftsent;
-    char tmp[10];
-    STACK_OF(X509) *systemCerts = sk_X509_new_null();
-    const char *dir_path[2];
-    X509 *cert;
-
-    dir_path[0] = dirpath;
-    dir_path[1] = NULL;
-
-    if (NULL == (fts = fts_open((char * const *) dir_path, FTS_LOGICAL, NULL))) {
-        printf("Fail to open directories. dir=%s \n", dirpath);
-        return NULL;
-    }
-
-    while ((ftsent = fts_read(fts)) != NULL) {
-        if (ftsent->fts_info == FTS_ERR || ftsent->fts_info == FTS_NS) {
-                printf("Fail to read directories. dir=%s \n", dirpath);
-                fts_close(fts);
-                return NULL;
-        }
-
-        if (ftsent->fts_info != FTS_F)
-            continue;
-
-        if (-1 != readlink(ftsent->fts_path, tmp, 10)) // ignore link file
-            continue;
-
-        cert = loadCert(ftsent->fts_path);
-        if(cert != NULL) {
-                sk_X509_push(systemCerts, cert);
-        }
-    }
-    if (fts != NULL)
-        fts_close(fts);
-
-    return systemCerts;
-}
-
-
-X509 *loadCert(const char *file) {
-    FILE *fp = fopen(file, "r");
-    if(fp == NULL)
-        return NULL;
-    X509 *cert;
-    if(!(cert = d2i_X509_fp(fp, NULL))) {
-        fseek(fp, 0, SEEK_SET);
-        cert = PEM_read_X509(fp, NULL, NULL, NULL);
-    }
-    fclose(fp);
-    return cert;
-}
-
-
-} // namespace CKM
-
diff --git a/src/manager/main/key-manager-util.h b/src/manager/main/key-manager-util.h
deleted file mode 100644 (file)
index b43b3fa..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *  Central Key Manager
- *
- *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *  Contact: Bumjin Im <bj.im@samsung.com>
- *
- *  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
- *
- */
-
-#ifndef CENT_KEY_MNG_UTIL_H
-#define CENT_KEY_MNG_UTIL_H
-
-#include <sys/types.h>
-#include <ckm/ckm-type.h>
-#include <openssl/x509v3.h>
-
-#define CKM_SYSTEM_CERTS_PATH "/opt/etc/ssl/certs"
-
-namespace CKM {
-
-int util_smack_label_is_valid(const char *smack_label);
-char *read_exe_path_from_proc(pid_t pid);
-
-void rawBufferToX509(X509 **ppCert, RawBuffer rawCert);
-void x509ToRawBuffer(RawBuffer &buf, X509 *cert);
-
-STACK_OF(X509) *loadSystemCerts( const char * dirpath);
-X509 *loadCert(const char *file);
-
-} // namespace CKM
-
-#endif /*CENT_KEY_MNG_UTIL_H*/
index 22815fc..c57c840 100644 (file)
@@ -22,7 +22,6 @@
 #include <ckm/ckm-type.h>
 #include <key-impl.h>
 #include <CryptoService.h>
-#include <key-manager-util.h>
 #include <assert.h>
 #include <dpl/log/log.h>
 
index 711883c..4f4477e 100644 (file)
@@ -28,7 +28,6 @@
 #include <openssl/ssl.h>
 #include <fts.h>
 #include <unistd.h>
-#include <key-manager-util.h>
 #include <dpl/log/log.h>
 #include <certificate-impl.h>
 #include <openssl_utils.h>