summaryrefslogtreecommitdiffstats
path: root/base/kra/functional/drmtest.py
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2014-07-24 11:20:12 -0400
committerAbhishek Koneru <akoneru@redhat.com>2014-08-27 01:15:35 -0400
commit6444287caa2ad171086d0ce9d93761a897247e06 (patch)
tree86e13cafc3f7b866be86b21cf0d96e401d0b9f01 /base/kra/functional/drmtest.py
parent8e464b6ba5d83d7915978db5841967f20672dfd0 (diff)
downloadpki-6444287caa2ad171086d0ce9d93761a897247e06.tar.gz
pki-6444287caa2ad171086d0ce9d93761a897247e06.tar.xz
pki-6444287caa2ad171086d0ce9d93761a897247e06.zip
Generate asymmetric keys in the DRM.
Adds methods to key client to generate asymmetric keys using algorithms RSA and DSA for a valid key sizes of 512, 1024, 2048,4096. The generated keys are archived in the database. Using the CLI, the public key(base64 encoded) can be retrieved by using the key-show command. The private key(base64 encoded) can be retrieved using the key-retrieve command. Ticket #1023
Diffstat (limited to 'base/kra/functional/drmtest.py')
-rw-r--r--base/kra/functional/drmtest.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/base/kra/functional/drmtest.py b/base/kra/functional/drmtest.py
index b309ce09f..4d65955f9 100644
--- a/base/kra/functional/drmtest.py
+++ b/base/kra/functional/drmtest.py
@@ -57,6 +57,12 @@ def print_key_info(key_info):
print "Status: " + str(key_info.status)
print "Owner Name: " + str(key_info.owner_name)
print "Size: " + str(key_info.size)
+ if key_info.public_key is not None:
+ print "Public key: "
+ print
+ pub_key = str(key_info.public_key)
+ for i in range(0, len(pub_key), 64):
+ print pub_key[i:i+64]
def print_key_data(key_data):
@@ -81,7 +87,7 @@ def main():
certdb_dir = "/tmp/drmtest-certdb"
certdb_password = "redhat123"
pki.crypto.NSSCryptoProvider.setup_database(certdb_dir, certdb_password,
- over_write=True)
+ over_write=True)
#create kraclient
crypto = pki.crypto.NSSCryptoProvider(certdb_dir, certdb_password)
@@ -260,6 +266,26 @@ def main():
print "Success: archived and recovered keys match"
else:
print "Error: archived and recovered keys do not match"
+ print
+
+ #Test 20: Generating asymmetric keys
+ print "Generating asymmetric keys"
+ try:
+ response = keyclient.generate_asymmetric_key(
+ "Vek #5" + time.strftime('%c'),
+ algorithm="RSA",
+ key_size=1024,
+ usages=None
+ )
+ print_key_request(response.request_info)
+ except pki.BadRequestException as exc:
+ print "BadRequestException thrown - Code:" + exc.code +\
+ " Message: " + exc.message
+
+ #Test 21: Get key information of the newly generated asymmetric keys
+ print "Retrieving key information"
+ key_info = keyclient.get_key_info(response.request_info.get_key_id())
+ print_key_info(key_info)
if __name__ == "__main__":
main()