[Cryptech-Commits] [sw/pkcs11] branch ksng updated: Track removal of `type` argument from hal_rpc_pkey_find().

git at cryptech.is git at cryptech.is
Fri Sep 16 19:53:26 UTC 2016


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch ksng
in repository sw/pkcs11.

The following commit(s) were added to refs/heads/ksng by this push:
       new  2d43319   Track removal of `type` argument from hal_rpc_pkey_find().
2d43319 is described below

commit 2d43319db94c0995ff5ce13f3f0da39ffbd12278
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Fri Sep 9 00:39:44 2016 -0400

    Track removal of `type` argument from hal_rpc_pkey_find().
---
 pkcs11.c   | 42 ++++++++++++++++++------------------------
 schema.sql |  1 -
 2 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/pkcs11.c b/pkcs11.c
index a482de0..e8bcb0f 100644
--- a/pkcs11.c
+++ b/pkcs11.c
@@ -1480,22 +1480,20 @@ static CK_OBJECT_HANDLE p11_object_create(const p11_session_t *session,
 
 static int p11_object_bind_pkey(const p11_session_t * const session,
                                 const CK_OBJECT_HANDLE object_handle,
-                                const hal_uuid_t * const pkey_uuid,
-                                const hal_key_type_t pkey_type)
+                                const hal_uuid_t * const pkey_uuid)
 {
   assert(session != NULL && pkey_uuid != NULL);
 
   static const char update_format[] =
-    " UPDATE %s_object SET hal_pkey_type = ?1, hal_pkey_uuid = ?2"
-    " WHERE %s_object_id = (SELECT %s_object_id FROM object WHERE object_handle = ?3)";
+    " UPDATE %s_object SET hal_pkey_uuid = ?1"
+    " WHERE %s_object_id = (SELECT %s_object_id FROM object WHERE object_handle = ?2)";
 
   const char *flavor = is_token_handle(object_handle) ? "token" : "session";
   sqlite3_stmt *q = NULL;
 
   int ok = (sql_check_ok(sql_prepare(&q, update_format, flavor, flavor, flavor))        &&
-            sql_check_ok(sqlite3_bind_int64(q, 1, pkey_type))                           &&
-            sql_check_ok(sqlite3_bind_blob( q, 2, pkey_uuid, sizeof(*pkey_uuid), NULL)) &&
-            sql_check_ok(sqlite3_bind_int64(q, 3, object_handle))                       &&
+            sql_check_ok(sqlite3_bind_blob( q, 1, pkey_uuid, sizeof(*pkey_uuid), NULL)) &&
+            sql_check_ok(sqlite3_bind_int64(q, 2, object_handle))                       &&
             sql_check_done(sqlite3_step(q)));
 
   sqlite3_finalize(q);
@@ -1542,7 +1540,7 @@ static inline int p11_object_create_rsa_public_key(const p11_session_t * const s
                                       p11_session_hal_session(session),
                                       &pkey, HAL_KEY_TYPE_RSA_PUBLIC, HAL_CURVE_NONE,
                                       &uuid, der, sizeof(der), flags))                          &&
-          p11_object_bind_pkey(session, object_handle, &uuid, HAL_KEY_TYPE_RSA_PUBLIC));
+          p11_object_bind_pkey(session, object_handle, &uuid));
   }
 
   if (!ok && pkey.handle != HAL_HANDLE_NONE)
@@ -1591,7 +1589,7 @@ static inline int p11_object_create_ec_public_key(const p11_session_t * const se
                                       p11_session_hal_session(session),
                                       &pkey, HAL_KEY_TYPE_EC_PUBLIC, curve,
                                       &uuid, der, sizeof(der), flags))                          &&
-          p11_object_bind_pkey(session, object_handle, &uuid, HAL_KEY_TYPE_EC_PUBLIC));
+          p11_object_bind_pkey(session, object_handle, &uuid));
   }
 
   if (!ok && pkey.handle != HAL_HANDLE_NONE)
@@ -1675,7 +1673,7 @@ static inline int p11_object_create_rsa_private_key(const p11_session_t * const
                                       p11_session_hal_session(session),
                                       &pkey, HAL_KEY_TYPE_RSA_PRIVATE, HAL_CURVE_NONE,
                                       &uuid, der, sizeof(der), flags))                          &&
-          p11_object_bind_pkey(session, object_handle, &uuid, HAL_KEY_TYPE_RSA_PRIVATE));
+          p11_object_bind_pkey(session, object_handle, &uuid));
     memset(der, 0, sizeof(der));
   }
 
@@ -1739,7 +1737,7 @@ static inline int p11_object_create_ec_private_key(const p11_session_t * const s
                                       p11_session_hal_session(session),
                                       &pkey, HAL_KEY_TYPE_EC_PRIVATE, curve,
                                       &uuid, der, sizeof(der), flags))                          &&
-          p11_object_bind_pkey(session, object_handle, &uuid, HAL_KEY_TYPE_EC_PRIVATE));
+          p11_object_bind_pkey(session, object_handle, &uuid));
     memset(der, 0, sizeof(der));
   }
 
@@ -1763,7 +1761,7 @@ static int p11_object_get_pkey_handle(const p11_session_t * const session,
                                       hal_pkey_handle_t *pkey_handle)
 {
   static const char select_format[] =
-    " SELECT hal_pkey_type, hal_pkey_uuid FROM %s_object NATURAL JOIN object WHERE object_handle = ?1";
+    " SELECT hal_pkey_uuid FROM %s_object NATURAL JOIN object WHERE object_handle = ?1";
 
   hal_key_flags_t flags = is_token_handle(object_handle) ? HAL_KEY_FLAG_TOKEN : 0;
   const char *flavor = is_token_handle(object_handle) ? "token" : "session";
@@ -1775,16 +1773,14 @@ static int p11_object_get_pkey_handle(const p11_session_t * const session,
   if (!sql_check_ok(sql_prepare(&q, select_format, flavor))     ||
       !sql_check_ok(sqlite3_bind_int64(q, 1, object_handle))    ||
       !sql_check_row(sqlite3_step(q))                           ||
-      sqlite3_column_type(q, 0) != SQLITE_INTEGER               ||
-      sqlite3_column_type(q, 1) != SQLITE_BLOB                  ||
-      sqlite3_column_bytes(q, 1) != sizeof(hal_uuid_t))
+      sqlite3_column_type(q, 0) != SQLITE_BLOB                  ||
+      sqlite3_column_bytes(q, 0) != sizeof(hal_uuid_t))
     goto fail;
 
-  const hal_key_type_t pkey_type = sqlite3_column_int64(q, 0);
-  const hal_uuid_t *   pkey_uuid = sqlite3_column_blob( q, 1);
+  const hal_uuid_t * const pkey_uuid = sqlite3_column_blob(q, 0);
 
   ok = hal_check(hal_rpc_pkey_find(p11_session_hal_client(session), p11_session_hal_session(session),
-                                   pkey_handle, pkey_type, pkey_uuid, flags));
+                                   pkey_handle, pkey_uuid, flags));
 
  fail:
   sqlite3_finalize(q);
@@ -2307,7 +2303,7 @@ static CK_RV generate_keypair_rsa_pkcs(p11_session_t *session,
                                            &pkey1, &uuid, keysize,
                                            public_exponent, public_exponent_len,
                                            private_flags))                                      ||
-      !p11_object_bind_pkey(session, private_handle, &uuid, HAL_KEY_TYPE_RSA_PRIVATE))
+      !p11_object_bind_pkey(session, private_handle, &uuid))
     lose(CKR_FUNCTION_FAILED);
 
   {
@@ -2335,8 +2331,7 @@ static CK_RV generate_keypair_rsa_pkcs(p11_session_t *session,
       lose(CKR_FUNCTION_FAILED);
   }
 
-  if (!p11_object_bind_pkey(session, public_handle,  &uuid,
-                            same_keystore ? HAL_KEY_TYPE_RSA_PRIVATE : HAL_KEY_TYPE_RSA_PUBLIC))
+  if (!p11_object_bind_pkey(session, public_handle,  &uuid))
     lose(CKR_FUNCTION_FAILED);
 
   rv = CKR_OK;
@@ -2392,7 +2387,7 @@ static CK_RV generate_keypair_ec(p11_session_t *session,
   if (!hal_check(hal_rpc_pkey_generate_ec(p11_session_hal_client(session),
                                           p11_session_hal_session(session),
                                           &pkey1, &uuid, curve, private_flags))                 ||
-      !p11_object_bind_pkey(session, private_handle, &uuid, HAL_KEY_TYPE_EC_PRIVATE)            ||
+      !p11_object_bind_pkey(session, private_handle, &uuid)                                     ||
       !p11_attribute_set(public_handle,  CKA_EC_PARAMS, params, params_len)                     ||
       !p11_attribute_set(private_handle, CKA_EC_PARAMS, params, params_len))
     lose(CKR_FUNCTION_FAILED);
@@ -2420,8 +2415,7 @@ static CK_RV generate_keypair_ec(p11_session_t *session,
       lose(CKR_FUNCTION_FAILED);
   }
 
-  if (!p11_object_bind_pkey(session, public_handle, &uuid,
-                            same_keystore ? HAL_KEY_TYPE_EC_PRIVATE : HAL_KEY_TYPE_EC_PUBLIC))
+  if (!p11_object_bind_pkey(session, public_handle, &uuid))
     lose(CKR_FUNCTION_FAILED);
 
   rv = CKR_OK;
diff --git a/schema.sql b/schema.sql
index 1db361c..ab675f8 100644
--- a/schema.sql
+++ b/schema.sql
@@ -77,7 +77,6 @@ CREATE TEMPORARY TABLE IF NOT EXISTS object (
 
 CREATE TEMPORARY TABLE IF NOT EXISTS session_object (
         session_object_id       INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
-        hal_pkey_type           INTEGER,
         hal_pkey_uuid           BLOB,
         object_id               INTEGER NOT NULL UNIQUE
                                 REFERENCES object

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list