* The following methods, properties and functions were added:
SecItem.type SecItem.len, SecItem.data PK11SymKey.key_data, PK11SymKey.key_length, PK11SymKey.slot create_context_by_sym_key param_from_iv generate_new_param get_iv_length get_block_size get_pad_mechanism * SecItem's now support indexing and slicing on their data * Clean up parsing and parameter validation of variable arg functions git-svn-id: svn://10.0.0.236/trunk@258428 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -23,4 +23,3 @@ src/py_nss.c
|
||||
src/py_nss.h
|
||||
src/py_ssl.c
|
||||
src/py_ssl.h
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
include LICENSE.mpl LICENSE.gpl LICENSE.lgpl
|
||||
recursive-include src *.c *.h *.py
|
||||
recursive-include lib *.py
|
||||
recursive-include doc ChangeLog *.txt *.py
|
||||
recursive-exclude doc http.py examples.py notes.txt coverage.txt
|
||||
@@ -1,3 +1,16 @@
|
||||
2009-09-21 John Dennis <jdennis@redhat.com> 0.8
|
||||
* The following methods, properties and functions were added:
|
||||
SecItem.type SecItem.len, SecItem.data
|
||||
PK11SymKey.key_data, PK11SymKey.key_length, PK11SymKey.slot
|
||||
create_context_by_sym_key
|
||||
param_from_iv
|
||||
generate_new_param
|
||||
get_iv_length
|
||||
get_block_size
|
||||
get_pad_mechanism
|
||||
* SecItem's now support indexing and slicing on their data
|
||||
* Clean up parsing and parameter validation of variable arg functions
|
||||
|
||||
2009-09-18 John Dennis <jdennis@redhat.com> 0.7
|
||||
* add support for symmetric encryption/decryption
|
||||
more support for digests (hashes)
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
# The Original Code is a Python binding for Network Security Services (NSS).
|
||||
#
|
||||
# The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
# (Author: John Dennis <jdennis@redhat.com>)
|
||||
#
|
||||
# (Author: John Dennis <jdennis@redhat.com>)
|
||||
#
|
||||
# Portions created by the Initial Developer are Copyright (C) 2008,2009
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
@@ -199,7 +199,7 @@ def Server():
|
||||
|
||||
if use_ssl:
|
||||
sock = ssl.SSLSocket()
|
||||
|
||||
|
||||
# Set server SSL socket options
|
||||
sock.set_pkcs11_pin_arg(password)
|
||||
sock.set_ssl_option(ssl.SSL_SECURITY, True)
|
||||
@@ -247,7 +247,7 @@ def Server():
|
||||
break
|
||||
|
||||
sock.shutdown()
|
||||
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ from distutils.util import subst_vars, change_root
|
||||
from distutils.command.build_py import build_py as _build_py
|
||||
from distutils.command.sdist import sdist as _sdist
|
||||
|
||||
version = "0.7"
|
||||
version = "0.8"
|
||||
|
||||
def update_version():
|
||||
"""If the version string in __init__.py doesn't match the current
|
||||
|
||||
@@ -296,4 +296,4 @@ FAQ
|
||||
To be added
|
||||
|
||||
"""
|
||||
__version__ = '0.7'
|
||||
__version__ = '0.8'
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,6 +41,7 @@
|
||||
|
||||
/* NSPR header files */
|
||||
#undef HAVE_LONG_LONG /* FIXME: both Python.h and nspr.h define HAVE_LONG_LONG */
|
||||
#include <stdbool.h>
|
||||
#include "nspr.h"
|
||||
#include "cert.h"
|
||||
#include "nss.h"
|
||||
@@ -110,6 +111,8 @@ typedef struct {
|
||||
SECItemKind kind;
|
||||
} SecItem;
|
||||
|
||||
#define SecItem_GET_SIZE(op) (Py_ssize_t)(op->item.len)
|
||||
|
||||
/* ========================================================================== */
|
||||
/* ============================ RSAPublicKey Class ========================== */
|
||||
/* ========================================================================== */
|
||||
@@ -172,7 +175,6 @@ typedef struct {
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
SECKEYPublicKey *pk;
|
||||
PyObject *py_pk11slot;
|
||||
PyObject *py_rsa_key;
|
||||
PyObject *py_dsa_key;
|
||||
} PublicKey;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# used for local testing
|
||||
#from test_util import insert_build_dir_into_path
|
||||
#insert_build_dir_into_path()
|
||||
|
||||
import sys
|
||||
import os
|
||||
import getopt
|
||||
@@ -28,14 +24,24 @@ def setup_contexts(mechanism, key, iv):
|
||||
print "generating key data"
|
||||
sym_key = slot.key_gen(mechanism, None, slot.get_best_key_length(mechanism))
|
||||
|
||||
# If initial value was supplied use it, otherwise set it to None
|
||||
# If initialization vector was supplied use it, otherwise set it to None
|
||||
if iv:
|
||||
if verbose:
|
||||
print "iv:\n%s" % (iv)
|
||||
iv_si = nss.SecItem(nss.read_hex(iv))
|
||||
print "supplied iv:\n%s" % (iv)
|
||||
iv_data = nss.read_hex(iv)
|
||||
iv_si = nss.SecItem(iv_data)
|
||||
iv_param = nss.param_from_iv(mechanism, iv_si)
|
||||
else:
|
||||
iv_param = None
|
||||
iv_length = nss.get_iv_length(mechanism)
|
||||
if iv_length > 0:
|
||||
iv_data = nss.generate_random(iv_length)
|
||||
iv_si = nss.SecItem(iv_data)
|
||||
iv_param = nss.param_from_iv(mechanism, iv_si)
|
||||
if verbose:
|
||||
print "generated %d byte initialization vector: %s" % \
|
||||
(iv_length, nss.data_to_hex(iv_data, separator=":"))
|
||||
else:
|
||||
iv_param = None
|
||||
|
||||
# Create an encoding context
|
||||
encoding_ctx = nss.create_context_by_sym_key(mechanism, nss.CKA_ENCRYPT,
|
||||
@@ -156,7 +162,7 @@ digest_test [-v -h] filename
|
||||
name is case insensitive, CKM_ prefix is optional
|
||||
-t --text plain text
|
||||
-k --key key (in hexadecimal format)
|
||||
-i --iv parameter initial value (in hexadecimal format)
|
||||
-i --iv initialization vector (in hexadecimal format)
|
||||
'''
|
||||
|
||||
def main():
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# used for local testing
|
||||
#from test_util import insert_build_dir_into_path
|
||||
#insert_build_dir_into_path()
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
@@ -37,11 +33,9 @@ def do_test(name, ref_cmd, nss_digest_func, hash_oid, in_filename, chunk_size):
|
||||
|
||||
hash_oid_name = nss.sec_oid_tag_str(hash_oid)
|
||||
|
||||
print "running test %s: nss_digest_func=%s hash_oid=%s" % \
|
||||
(name, nss_digest_func.__name__, hash_oid_name)
|
||||
|
||||
print nss.sec_oid_tag_from_name("sha512")
|
||||
print "%s = %d" % (nss.sec_oid_tag_name(hash_oid), nss.sec_oid_tag_from_name(nss.sec_oid_tag_name(hash_oid)))
|
||||
if verbose:
|
||||
print "running test %s: nss_digest_func=%s hash_oid=%s" % \
|
||||
(name, nss_digest_func.__name__, hash_oid_name)
|
||||
|
||||
# read the data in from the file
|
||||
ref_data = open(in_filename).read()
|
||||
@@ -59,8 +53,6 @@ def do_test(name, ref_cmd, nss_digest_func, hash_oid, in_filename, chunk_size):
|
||||
reference_digest = proc.stdout.read().split()[0]
|
||||
if verbose:
|
||||
print "reference_digest\n%s" % (reference_digest)
|
||||
else:
|
||||
print reference_digest
|
||||
|
||||
# Run the test with convenience digest function (e.g. nss.sha256_digest, etc.).
|
||||
test_digest = nss.data_to_hex(nss_digest_func(ref_data))
|
||||
|
||||
Reference in New Issue
Block a user