Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
862bfe02
authored
Feb 04, 2013
by
Őry, Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
laborclient: add RSA generator
parent
3e25c230
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
15 deletions
+39
-15
miscellaneous/laborclient/store_gui.py
+39
-15
No files found.
miscellaneous/laborclient/store_gui.py
View file @
862bfe02
#!/usr/bin/env python
import
RSA
import
gtk
import
webkit
import
gobject
...
...
@@ -8,25 +7,50 @@ import base64
import
subprocess
import
os
def
keygen
(
length
=
1024
):
import
os
,
base64
from
datetime
import
date
from
Crypto.PublicKey
import
RSA
key
=
RSA
.
generate
(
length
,
os
.
urandom
)
try
:
pub
=
key
.
exportKey
(
'OpenSSH'
)
if
not
pub
.
startswith
(
"ssh-"
):
raise
ValueError
(
pub
)
except
:
ssh_rsa
=
'00000007'
+
base64
.
b16encode
(
'ssh-rsa'
)
exponent
=
'
%
x'
%
(
key
.
e
,
)
if
len
(
exponent
)
%
2
:
exponent
=
'0'
+
exponent
ssh_rsa
+=
'
%08
x'
%
(
len
(
exponent
)
/
2
,
)
ssh_rsa
+=
exponent
modulus
=
'
%
x'
%
(
key
.
n
,
)
if
len
(
modulus
)
%
2
:
modulus
=
'0'
+
modulus
if
modulus
[
0
]
in
'89abcdef'
:
modulus
=
'00'
+
modulus
ssh_rsa
+=
'
%08
x'
%
(
len
(
modulus
)
/
2
,
)
ssh_rsa
+=
modulus
pub
=
'ssh-rsa
%
s'
%
(
base64
.
b64encode
(
base64
.
b16decode
(
ssh_rsa
.
upper
())),
)
return
key
.
exportKey
(),
"
%
s
%
s"
%
(
pub
,
"cloud-
%
s"
%
date
.
today
())
### Settings ###
KEY_DIR
=
"/
home/tarokkk/Dropbox/python
/"
KEY_DIR
=
"/
tmp
/"
KEY_FILE
=
KEY_DIR
+
"/id_rsa"
#Initalize keypair
private_key
=
RSA
.
generate
(
2048
)
public_key
=
private_key
.
publickey
()
private_key
,
public_key
=
keygen
(
2048
)
#Saver private_key
f
=
open
(
KEY_FILE
,
'w'
)
f
.
write
(
private_key
.
exportKey
())
f
.
close
()
open_ssh_key
=
public_key
.
exportKey
(
'OpenSSH'
)
os
.
chmod
(
KEY_FILE
,
0600
)
f
=
open
(
KEY_DIR
+
'/'
+
'id_rsa.pub'
,
'w'
)
f
.
write
(
open_ssh_key
)
f
.
close
()
pub_key_string
=
base64
.
b64encode
(
open_ssh_key
)
#print pub_key_string
with
open
(
KEY_FILE
,
'w'
)
as
f
:
f
.
write
(
private_key
)
pub_key_string
=
base64
.
b64encode
(
public_key
)
class
Browser
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment