Skip to content

Commit deb50ad

Browse files
authored
Merge pull request #300 from lukpueh/adopt-288-in-readme
Adopt interface changes (#288) in README snippets
2 parents 92da669 + 43deff7 commit deb50ad

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

README.rst

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,16 @@ text without prepended symbols is the output of a command.
7979
# the current working directory). A full directory path may be specified
8080
# instead of saving keys to the current working directory. If specified
8181
# directories do not exist, they will be created.
82-
>>> generate_and_write_rsa_keypair("rsa_key1", bits=2048, password="password")
82+
>>> generate_and_write_rsa_keypair(
83+
password="password", filepath="rsa_key1", bits=2048)
8384

8485
# If the key length is unspecified, it defaults to 3072 bits. A length of
85-
# less than 2048 bits raises an exception. A password may be supplied as an
86-
# argument like above, or on the prompt. If no password is passed or
87-
# entered the private key is saved unencrypted.
88-
>>> generate_and_write_rsa_keypair("rsa_key2", prompt=True)
89-
Enter a password for the RSA key:
86+
# less than 2048 bits raises an exception. A similar function is available
87+
# to supply a password on the prompt. If an empty password is entered, the
88+
# private key is saved unencrypted.
89+
>>> generate_and_write_rsa_keypair_with_prompt("rsa_key2")
90+
enter password to encrypt private key file '/path/to/rsa_key2'
91+
(leave empty if key should not be encrypted):
9092
Confirm:
9193

9294

@@ -110,10 +112,11 @@ Import RSA Keys
110112
# Import an existing private key. If your private key is encrypted,
111113
# which it should be, you either have to pass a 'password' or enter one
112114
# on the prompt.
113-
>>> private_rsa_key1 = import_rsa_privatekey_from_file("rsa_key1", password='some passphrase")
114-
OR:
115+
>>> private_rsa_key1 = import_rsa_privatekey_from_file("rsa_key1", password="some passphrase")
116+
# OR:
115117
>>> private_rsa_key1 = import_rsa_privatekey_from_file("rsa_key1", prompt=True)
116-
Enter a password for the encrypted RSA key:
118+
enter password to decrypt private key file '/path/to/rsa_key1'
119+
(leave empty if key not encrypted):
117120

118121
**import_rsa_privatekey_from_file()** raises a
119122
*securesystemslib.exceptions.CryptoError* exception if the key / password is
@@ -134,36 +137,35 @@ Create and Import Ed25519 Keys
134137

135138
# Continuing from the previous section . . .
136139

137-
# Generate and write an Ed25519 key pair. A password may be supplied as an
138-
# argument, or on the prompt. If no password is passed or entered the
139-
# private key is saved unencrypted.
140-
>>> generate_and_write_ed25519_keypair('ed25519_key', prompt=True)
141-
Enter a password for the Ed25519 key:
140+
# The same generation and import functions as for rsa keys exist for ed25519
141+
>>> generate_and_write_ed25519_keypair_with_prompt('ed25519_key')
142+
enter password to encrypt private key file '/path/to/ed25519_key'
143+
(leave empty if key should not be encrypted):
142144
Confirm:
143145

144146
# Import the Ed25519 public key just created . . .
145147
>>> public_ed25519_key = import_ed25519_publickey_from_file('ed25519_key.pub')
146148

147149
# and its corresponding private key.
148150
>>> private_ed25519_key = import_ed25519_privatekey_from_file('ed25519_key', prompt=True)
149-
Enter a password for the encrypted Ed25519 key:
150-
151+
enter password to decrypt private key file '/path/to/ed25519_key'
152+
(leave empty if key should not be encrypted):
151153

152154
Create and Import ECDSA Keys
153155
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154156

155157
::
156158

157-
# continuing from the previous sections . . .
158-
159-
>>> generate_and_write_ecdsa_keypair('ecdsa_key', prompt=True)
160-
Enter a password for the ECDSA key:
161-
Confirm:
159+
# The same generation and import functions as for rsa and ed25519 keys
160+
# exist for ecdsa
161+
>>> generate_and_write_ecdsa_keypair_with_prompt('ecdsa_key')
162+
enter password to decrypt private key file '/path/to/ecdsa_key'
163+
(leave empty if key should not be encrypted):
162164

163165
>>> public_ecdsa_key = import_ecdsa_publickey_from_file('ecdsa_key.pub')
164166
>>> private_ecdsa_key = import_ecdsa_privatekey_from_file('ecdsa_key', prompt=True)
165-
Enter a password for the encrypted ECDSA key:
166-
167+
enter password to decrypt private key file '/path/to/ecdsa_key'
168+
(leave empty if key should not be encrypted):
167169

168170
Generate ECDSA, Ed25519, and RSA Signatures
169171
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)