Skip to content

Commit 560f66c

Browse files
author
Lukas Puehringer
committed
Remove/re-word TUF code comments
1 parent d5e0981 commit 560f66c

File tree

7 files changed

+66
-66
lines changed

7 files changed

+66
-66
lines changed

securesystemslib/ed25519_keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
except (ImportError, IOError): # pragma: no cover
101101
pass
102102

103-
# The optimized pure Python implementation of Ed25519 provided by TUF. If
103+
# The optimized pure Python implementation of Ed25519. If
104104
# PyNaCl cannot be imported and an attempt to use is made in this module, a
105105
# 'securesystemslib.exceptions.UnsupportedLibraryError' exception is raised.
106106
import securesystemslib._vendor.ed25519.ed25519

securesystemslib/formats.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
See LICENSE for licensing information.
1616
1717
<Purpose>
18-
A central location for all format-related checking of TUF objects.
19-
Note: 'formats.py' depends heavily on 'schema.py', so the 'schema.py'
20-
module should be read and understood before tackling this module.
18+
A central location for all format-related checking of securesystemslib
19+
objects. Note: 'formats.py' depends heavily on 'schema.py', so the
20+
'schema.py' module should be read and understood before tackling this module.
2121
2222
'formats.py' can be broken down into three sections. (1) Schemas and object
2323
matching. (2) Classes that represent Role Metadata and help produce
24-
correctly formatted files. (3) Functions that help produce or verify TUF
25-
objects.
24+
correctly formatted files. (3) Functions that help produce or verify
25+
securesystemslib objects.
2626
2727
The first section deals with schemas and object matching based on format.
2828
There are two ways of checking the format of objects. The first method
@@ -57,7 +57,7 @@
5757
schema to ensure correctly formatted metadata.
5858
5959
The last section contains miscellaneous functions related to the format of
60-
TUF objects.
60+
securesystemslib objects.
6161
Example:
6262
6363
signable_object = make_signable(unsigned_object)
@@ -148,7 +148,7 @@
148148
SCHEMA.String('sha224'), SCHEMA.String('sha256'),
149149
SCHEMA.String('sha384'), SCHEMA.String('sha512')]))
150150

151-
# The contents of an encrypted TUF key. Encrypted TUF keys are saved to files
151+
# The contents of an encrypted key. Encrypted keys are saved to files
152152
# in this format.
153153
ENCRYPTEDKEY_SCHEMA = SCHEMA.AnyString()
154154

@@ -194,13 +194,13 @@
194194
public = SCHEMA.AnyString(),
195195
private = SCHEMA.Optional(SCHEMA.String("")))
196196

197-
# Supported TUF key types.
197+
# Supported securesystemslib key types.
198198
KEYTYPE_SCHEMA = SCHEMA.OneOf(
199199
[SCHEMA.String('rsa'), SCHEMA.String('ed25519'),
200200
SCHEMA.String('ecdsa-sha2-nistp256')])
201201

202-
# A generic TUF key. All TUF keys should be saved to metadata files in this
203-
# format.
202+
# A generic securesystemslib key. All securesystemslib keys should be saved to
203+
# metadata files in this format.
204204
KEY_SCHEMA = SCHEMA.Object(
205205
object_name = 'KEY_SCHEMA',
206206
keytype = SCHEMA.AnyString(),
@@ -218,8 +218,9 @@
218218
keyval = PUBLIC_KEYVAL_SCHEMA,
219219
expires = SCHEMA.Optional(ISO8601_DATETIME_SCHEMA))
220220

221-
# A TUF key object. This schema simplifies validation of keys that may be one
222-
# of the supported key types. Supported key types: 'rsa', 'ed25519'.
221+
# A securesystemslib key object. This schema simplifies validation of keys
222+
# that may be one of the supported key types. Supported key types: 'rsa',
223+
# 'ed25519'.
223224
ANYKEY_SCHEMA = SCHEMA.Object(
224225
object_name = 'ANYKEY_SCHEMA',
225226
keytype = KEYTYPE_SCHEMA,
@@ -229,15 +230,15 @@
229230
keyval = KEYVAL_SCHEMA,
230231
expires = SCHEMA.Optional(ISO8601_DATETIME_SCHEMA))
231232

232-
# A list of TUF key objects.
233+
# A list of securesystemslib key objects.
233234
ANYKEYLIST_SCHEMA = SCHEMA.ListOf(ANYKEY_SCHEMA)
234235

235236
# RSA signature schemes.
236237
RSA_SCHEME_SCHEMA = SCHEMA.OneOf([
237238
SCHEMA.RegularExpression(r'rsassa-pss-(md5|sha1|sha224|sha256|sha384|sha512)'),
238239
SCHEMA.RegularExpression(r'rsa-pkcs1v15-(md5|sha1|sha224|sha256|sha384|sha512)')])
239240

240-
# An RSA TUF key.
241+
# An RSA securesystemslib key.
241242
RSAKEY_SCHEMA = SCHEMA.Object(
242243
object_name = 'RSAKEY_SCHEMA',
243244
keytype = SCHEMA.String('rsa'),
@@ -246,7 +247,7 @@
246247
keyid_hash_algorithms = SCHEMA.Optional(HASHALGORITHMS_SCHEMA),
247248
keyval = KEYVAL_SCHEMA)
248249

249-
# An ECDSA TUF key.
250+
# An ECDSA securesystemslib key.
250251
ECDSAKEY_SCHEMA = SCHEMA.Object(
251252
object_name = 'ECDSAKEY_SCHEMA',
252253
keytype = SCHEMA.String('ecdsa-sha2-nistp256'),
@@ -277,7 +278,7 @@
277278
# supported.
278279
ED25519_SIG_SCHEMA = SCHEMA.OneOf([SCHEMA.String('ed25519')])
279280

280-
# An ed25519 TUF key.
281+
# An ed25519 key.
281282
ED25519KEY_SCHEMA = SCHEMA.Object(
282283
object_name = 'ED25519KEY_SCHEMA',
283284
keytype = SCHEMA.String('ed25519'),
@@ -543,13 +544,13 @@ def encode_canonical(object, output_function=None):
543544
or joined into a string and returned.
544545
545546
Note: This function should be called prior to computing the hash or
546-
signature of a JSON object in TUF. For example, generating a signature
547-
of a signing role object such as 'ROOT_SCHEMA' is required to ensure
548-
repeatable hashes are generated across different json module versions
549-
and platforms. Code elsewhere is free to dump JSON objects in any format
550-
they wish (e.g., utilizing indentation and single quotes around object
551-
keys). These objects are only required to be in "canonical JSON" format
552-
when their hashes or signatures are needed.
547+
signature of a JSON object in securesystemslib. For example, generating a
548+
signature of a signing role object such as 'ROOT_SCHEMA' is required to
549+
ensure repeatable hashes are generated across different json module
550+
versions and platforms. Code elsewhere is free to dump JSON objects in any
551+
format they wish (e.g., utilizing indentation and single quotes around
552+
object keys). These objects are only required to be in "canonical JSON"
553+
format when their hashes or signatures are needed.
553554
554555
>>> encode_canonical("")
555556
'""'

securesystemslib/hash.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
1515
<Purpose>
1616
Support secure hashing and message digests. Any hash-related routines that
17-
TUF requires should be located in this module. Simplifying the creation of
18-
digest objects, and providing a central location for hash routines are the
19-
main goals of this module. Support routines implemented include functions to
20-
create digest objects given a filename or file object. Only the standard
21-
hashlib library is currently supported, but pyca/cryptography support will be
22-
added in the future.
17+
securesystemslib requires should be located in this module. Simplifying the
18+
creation of digest objects, and providing a central location for hash
19+
routines are the main goals of this module. Support routines implemented
20+
include functions to create digest objects given a filename or file object.
21+
Only the standard hashlib library is currently supported, but
22+
pyca/cryptography support will be added in the future.
2323
"""
2424

2525
# Help with Python 3 compatibility, where the print statement is a function, an

securesystemslib/pyca_crypto_keys.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
https://en.wikipedia.org/wiki/PBKDF
4141
http://en.wikipedia.org/wiki/Scrypt
4242
43-
TUF key files are encrypted with the AES-256-CTR-Mode symmetric key
44-
algorithm. User passwords are strengthened with PBKDF2, currently set to
43+
securesystemslib key files are encrypted with the AES-256-CTR-Mode symmetric
44+
key algorithm. User passwords are strengthened with PBKDF2, currently set to
4545
100,000 passphrase iterations. The previous evpy implementation used 1,000
4646
iterations.
4747
@@ -98,7 +98,7 @@
9898
# Import pyca/cryptography's Key Derivation Function (KDF) module.
9999
# 'securesystemslib.keys.py' needs this module to derive a secret key according
100100
# to the Password-Based Key Derivation Function 2 specification. The derived
101-
# key is used as the symmetric key to encrypt TUF key information.
101+
# key is used as the symmetric key to encrypt securesystemslib key information.
102102
# PKCS#5 v2.0 PBKDF2 specification: http://tools.ietf.org/html/rfc2898#section-5.2
103103
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
104104

@@ -573,7 +573,7 @@ def create_rsa_public_and_private_from_pem(pem, passphrase=None):
573573
strengthened'passphrase', and 3DES with CBC mode for encryption/decryption.
574574
Alternatively, key data may be encrypted with AES-CTR-Mode and the
575575
passphrase strengthened with PBKDF2+SHA256, although this method is used
576-
only with TUF encrypted key files.
576+
only with securesystemslib encrypted key files.
577577
578578
>>> public, private = generate_rsa_public_and_private(2048)
579579
>>> passphrase = 'secret'
@@ -679,16 +679,16 @@ def encrypt_key(key_object, password):
679679
Return a string containing 'key_object' in encrypted form. Encrypted
680680
strings may be safely saved to a file. The corresponding decrypt_key()
681681
function can be applied to the encrypted string to restore the original key
682-
object. 'key_object' is a TUF key (e.g., RSAKEY_SCHEMA,
682+
object. 'key_object' is a securesystemslib key (e.g., RSAKEY_SCHEMA,
683683
ED25519KEY_SCHEMA). This function calls the pyca/cryptography library to
684684
perform the encryption and derive a suitable encryption key.
685685
686686
Whereas an encrypted PEM file uses the Triple Data Encryption Algorithm
687687
(3DES), the Cipher-block chaining (CBC) mode of operation, and the Password
688688
Based Key Derivation Function 1 (PBKF1) + MD5 to strengthen 'password',
689-
encrypted TUF keys use AES-256-CTR-Mode and passwords strengthened with
690-
PBKDF2-HMAC-SHA256 (100K iterations by default, but may be overriden in
691-
'settings.PBKDF2_ITERATIONS' by the user).
689+
encrypted securesystemslib keys use AES-256-CTR-Mode and passwords
690+
strengthened with PBKDF2-HMAC-SHA256 (100K iterations by default, but may
691+
be overriden in 'settings.PBKDF2_ITERATIONS' by the user).
692692
693693
http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
694694
http://en.wikipedia.org/wiki/CTR_mode#Counter_.28CTR.29
@@ -709,8 +709,8 @@ def encrypt_key(key_object, password):
709709
710710
<Arguments>
711711
key_object:
712-
The TUF key object that should contain the private portion of the ED25519
713-
key.
712+
The securesystemslib key object that should contain the private portion
713+
of the ED25519 key.
714714
715715
password:
716716
The password, or passphrase, to encrypt the private part of the RSA
@@ -722,8 +722,8 @@ def encrypt_key(key_object, password):
722722
improperly formatted or 'key_object' does not contain the private portion
723723
of the key.
724724
725-
securesystemslib.exceptions.CryptoError, if an Ed25519 key in encrypted TUF
726-
format cannot be created.
725+
securesystemslib.exceptions.CryptoError, if an Ed25519 key in encrypted
726+
securesystemslib format cannot be created.
727727
728728
<Side Effects>
729729
pyca/Cryptography cryptographic operations called to perform the actual
@@ -774,13 +774,13 @@ def decrypt_key(encrypted_key, password):
774774
<Purpose>
775775
Return a string containing 'encrypted_key' in non-encrypted form.
776776
The decrypt_key() function can be applied to the encrypted string to restore
777-
the original key object, a TUF key (e.g., RSAKEY_SCHEMA, ED25519KEY_SCHEMA).
778-
This function calls the appropriate cryptography module (i.e.,
779-
pyca_crypto_keys.py) to perform the decryption.
777+
the original key object, a securesystemslib key (e.g., RSAKEY_SCHEMA,
778+
ED25519KEY_SCHEMA). This function calls the appropriate cryptography module
779+
(i.e., pyca_crypto_keys.py) to perform the decryption.
780780
781-
Encrypted TUF keys use AES-256-CTR-Mode and passwords strengthened with
782-
PBKDF2-HMAC-SHA256 (100K iterations be default, but may be overriden in
783-
'settings.py' by the user).
781+
Encrypted securesystemslib keys use AES-256-CTR-Mode and passwords
782+
strengthened with PBKDF2-HMAC-SHA256 (100K iterations be default, but may
783+
be overriden in 'settings.py' by the user).
784784
785785
http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
786786
http://en.wikipedia.org/wiki/CTR_mode#Counter_.28CTR.29
@@ -804,9 +804,9 @@ def decrypt_key(encrypted_key, password):
804804
805805
<Arguments>
806806
encrypted_key:
807-
An encrypted TUF key (additional data is also included, such as salt,
808-
number of password iterations used for the derived encryption key, etc)
809-
of the form 'securesystemslib.formats.ENCRYPTEDKEY_SCHEMA'.
807+
An encrypted securesystemslib key (additional data is also included, such
808+
as salt, number of password iterations used for the derived encryption
809+
key, etc) of the form 'securesystemslib.formats.ENCRYPTEDKEY_SCHEMA'.
810810
'encrypted_key' should have been generated with encrypted_key().
811811
812812
password:
@@ -818,11 +818,11 @@ def decrypt_key(encrypted_key, password):
818818
securesystemslib.exceptions.FormatError, if the arguments are improperly
819819
formatted.
820820
821-
securesystemslib.exceptions.CryptoError, if a TUF key cannot be decrypted
822-
from 'encrypted_key'.
821+
securesystemslib.exceptions.CryptoError, if a securesystemslib key cannot
822+
be decrypted from 'encrypted_key'.
823823
824-
securesystemslib.exceptions.Error, if a valid TUF key object is not found in
825-
'encrypted_key'.
824+
securesystemslib.exceptions.Error, if a valid securesystemslib key object
825+
is not found in 'encrypted_key'.
826826
827827
<Side Effects>
828828
The pyca/cryptography is library called to perform the actual decryption

securesystemslib/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
3939
'schema.py' provides additional schemas for testing objects based on other
4040
criteria. See 'securesystemslib.formats.py' and the rest of this module for
41-
extensive examples. Anything related to the checking of TUF objects and
42-
their formats can be found in 'formats.py'.
41+
extensive examples. Anything related to the checking of securesystemslib
42+
objects and their formats can be found in 'formats.py'.
4343
"""
4444

4545
# Help with Python 3 compatibility, where the print statement is a function, an

securesystemslib/util.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
# to the filenames of consistent snapshots.
4545
HASH_FUNCTION = 'sha256'
4646

47-
# See 'log.py' to learn how logging is handled in TUF.
4847
logger = logging.getLogger('securesystemslib_util')
4948

5049

@@ -470,12 +469,12 @@ def file_in_confined_directories(filepath, confined_directories):
470469
return True
471470

472471
# Normalized paths needed, to account for up-level references, etc.
473-
# TUF clients have the option of setting the list of directories in
472+
# callers have the option of setting the list of directories in
474473
# 'confined_directories'.
475474
filepath = os.path.normpath(filepath)
476475
confined_directory = os.path.normpath(confined_directory)
477476

478-
# A TUF client may restrict himself to specific directories on the
477+
# A caller may restrict himself to specific directories on the
479478
# remote repository. The list of paths in 'confined_path', not including
480479
# each path's subdirectories, are the only directories the client will
481480
# download targets from.
@@ -557,11 +556,11 @@ def import_json():
557556
return _json_module
558557

559558
else:
559+
# TODO: Drop Python < 2.6 case handling
560560
try:
561561
module = __import__('json')
562-
563562
# The 'json' module is available in Python > 2.6, and thus this exception
564-
# should not occur in all supported Python installations (> 2.6) of TUF.
563+
# should not occur in all supported Python installations (> 2.6).
565564
except ImportError: #pragma: no cover
566565
raise ImportError('Could not import the json module')
567566

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<Purpose>
1717
BUILD SOURCE DISTRIBUTION
1818
19-
The following shell command generates a TUF source archive that can be
20-
distributed to other users. The packaged source is saved to the 'dist'
21-
folder in the current directory.
19+
The following shell command generates a securesystemslib source archive that
20+
can be distributed to other users. The packaged source is saved to the
21+
'dist' folder in the current directory.
2222
2323
$ python setup.py sdist
2424
@@ -54,7 +54,7 @@
5454
Note: The last two installation options may require modification of
5555
Python's search path (i.e., 'sys.path') or updating an OS environment
5656
variable. For example, installing to the user site-packages directory might
57-
result in the installation of TUF scripts to '~/.local/bin'. The user may
57+
result in the installation of scripts to '~/.local/bin'. The user may
5858
then be required to update his $PATH variable:
5959
$ export PATH=$PATH:~/.local/bin
6060
"""

0 commit comments

Comments
 (0)