Initial snapshot
This commit is contained in:
commit
fee4dd4e6d
373 changed files with 62144 additions and 0 deletions
47
test/packages/ktp/key.py
Normal file
47
test/packages/ktp/key.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#
|
||||
# ---------- header -----------------------------------------------------------
|
||||
#
|
||||
# project kaneton
|
||||
#
|
||||
# license kaneton
|
||||
#
|
||||
# file /home/mycure/KANETON-TEST-SYSTEM/packages/ktp/key.py
|
||||
#
|
||||
# created julien quintard [mon oct 25 20:11:55 2010]
|
||||
# updated julien quintard [wed oct 27 13:11:59 2010]
|
||||
#
|
||||
|
||||
#
|
||||
# ---------- packages ---------------------------------------------------------
|
||||
#
|
||||
|
||||
from OpenSSL import crypto
|
||||
|
||||
#
|
||||
# ---------- definitions ------------------------------------------------------
|
||||
#
|
||||
|
||||
Extension = ".key"
|
||||
|
||||
#
|
||||
# ---------- functions --------------------------------------------------------
|
||||
#
|
||||
|
||||
#
|
||||
# this function generates a cryptographic key.
|
||||
#
|
||||
def Generate(type = crypto.TYPE_RSA,
|
||||
length = 2048):
|
||||
key = crypto.PKey()
|
||||
|
||||
key.generate_key(type, length)
|
||||
|
||||
return key
|
||||
|
||||
#
|
||||
# this function stores a key.
|
||||
#
|
||||
def Store(path,
|
||||
key):
|
||||
open(path,
|
||||
'w').write(crypto.dump_privatekey(crypto.FILETYPE_PEM, key))
|
||||
Reference in a new issue