Skip to content

Commit cf88e3f

Browse files
committed
Crypto: Standardize naming where use of "family" and "type" have been used. Prefer 'type'.
1 parent bba541c commit cf88e3f

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

cpp/ql/lib/experimental/quantum/OpenSSL/AlgorithmInstances/EllipticCurveAlgorithmInstance.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class KnownOpenSslEllipticCurveConstantAlgorithmInstance extends OpenSslAlgorith
4040
result = this.(Call).getTarget().getName()
4141
}
4242

43-
override Crypto::EllipticCurveFamilyType getEllipticCurveFamilyType() {
43+
override Crypto::EllipticCurveType getEllipticCurveType() {
4444
if
4545
Crypto::ellipticCurveNameToKnownKeySizeAndFamilyMapping(this.getParsedEllipticCurveName(), _,
4646
_)

cpp/ql/lib/experimental/quantum/OpenSSL/AlgorithmInstances/HashAlgorithmInstance.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class KnownOpenSslHashConstantAlgorithmInstance extends OpenSslAlgorithmInstance
7272

7373
override OpenSslAlgorithmValueConsumer getAvc() { result = getterCall }
7474

75-
override Crypto::THashType getHashFamily() {
75+
override Crypto::THashType getHashType() {
7676
knownOpenSslConstantToHashFamilyType(this, result)
7777
or
7878
not knownOpenSslConstantToHashFamilyType(this, _) and result = Crypto::OtherHashType()

java/ql/lib/experimental/quantum/JCA.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ module JCAModel {
426426

427427
override string getRawHashAlgorithmName() { result = super.getPadding() }
428428

429-
override Crypto::THashType getHashFamily() { result = hash_name_to_type_known(hashName, _) }
429+
override Crypto::THashType getHashType() { result = hash_name_to_type_known(hashName, _) }
430430

431431
override int getFixedDigestLength() { exists(hash_name_to_type_known(hashName, result)) }
432432
}
@@ -859,7 +859,7 @@ module JCAModel {
859859

860860
override string getRawHashAlgorithmName() { result = super.getValue() }
861861

862-
override Crypto::THashType getHashFamily() {
862+
override Crypto::THashType getHashType() {
863863
result = hash_name_to_type_known(this.getRawHashAlgorithmName(), _)
864864
}
865865

@@ -1302,7 +1302,7 @@ module JCAModel {
13021302

13031303
override string getRawHashAlgorithmName() { result = this.(StringLiteral).getValue() }
13041304

1305-
override Crypto::THashType getHashFamily() { result = hash_name_to_type_known(hashName, _) }
1305+
override Crypto::THashType getHashType() { result = hash_name_to_type_known(hashName, _) }
13061306

13071307
override int getFixedDigestLength() { exists(hash_name_to_type_known(hashName, result)) }
13081308
}
@@ -1770,7 +1770,7 @@ module JCAModel {
17701770

17711771
override string getRawHashAlgorithmName() { result = this.(StringLiteral).getValue() }
17721772

1773-
override Crypto::THashType getHashFamily() { result = hashType }
1773+
override Crypto::THashType getHashType() { result = hashType }
17741774

17751775
override int getFixedDigestLength() { result = digestLength }
17761776
}
@@ -1905,7 +1905,7 @@ module JCAModel {
19051905

19061906
override string getRawEllipticCurveName() { result = super.getValue() }
19071907

1908-
override Crypto::EllipticCurveFamilyType getEllipticCurveFamilyType() {
1908+
override Crypto::EllipticCurveType getEllipticCurveType() {
19091909
if
19101910
Crypto::ellipticCurveNameToKnownKeySizeAndFamilyMapping(this.getRawEllipticCurveName(), _, _)
19111911
then

shared/quantum/codeql/quantum/experimental/Model.qll

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -825,20 +825,20 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
825825
*/
826826
abstract string getRawEllipticCurveName();
827827

828-
abstract TEllipticCurveFamilyType getEllipticCurveFamilyType();
828+
abstract TEllipticCurveType getEllipticCurveType();
829829

830830
abstract int getKeySize();
831831

832832
/**
833833
* The 'parsed' curve name, e.g., "P-256" or "secp256r1"
834-
* The parsed name is full name of the curve, including the family, key size, and other
834+
* The parsed name is full name of the curve, including the type, key size, and other
835835
* typical parameters found on the name.
836836
*
837837
* In many cases this will be equivalent to `getRawEllipticCurveAlgorithmName()`,
838838
* but not always (e.g., if the curve is specified through a raw NID).
839839
*
840840
* In cases like an NID, we want the standardized name so users can quickly
841-
* understand what the curve is, while also parsing out the family and key size
841+
* understand what the curve is, while also parsing out the type and key size
842842
* separately.
843843
*/
844844
string getParsedEllipticCurveName() { result = this.getRawEllipticCurveName() }
@@ -854,7 +854,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
854854
/**
855855
* Gets the type of this digest algorithm, e.g., "SHA1", "SHA2", "MD5" etc.
856856
*/
857-
abstract THashType getHashFamily();
857+
abstract THashType getHashType();
858858

859859
/**
860860
* Gets the isolated name as it appears in source, e.g., "SHA-256" in "SHA-256/PKCS7Padding".
@@ -2293,13 +2293,13 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
22932293
*
22942294
* When modeling a new hashing algorithm, use this predicate to specify the type of the algorithm.
22952295
*/
2296-
HashType getHashFamily() { result = instance.asAlg().getHashFamily() }
2296+
HashType getHashType() { result = instance.asAlg().getHashType() }
22972297

2298-
override string getAlgorithmName() { result = this.getHashFamily().toString() }
2298+
override string getAlgorithmName() { result = this.getHashType().toString() }
22992299

23002300
int getDigestLength() {
23012301
result = instance.asAlg().getFixedDigestLength() or
2302-
fixedImplicitDigestLength(instance.asAlg().getHashFamily(), result)
2302+
fixedImplicitDigestLength(instance.asAlg().getHashType(), result)
23032303
}
23042304

23052305
final override predicate properties(string key, string value, Location location) {
@@ -2340,9 +2340,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
23402340

23412341
override string getAlgorithmName() { result = this.getRawAlgorithmName() }
23422342

2343-
EllipticCurveFamilyType getEllipticCurveFamilyType() {
2344-
result = instance.asAlg().getEllipticCurveFamilyType()
2345-
}
2343+
EllipticCurveType getEllipticCurveType() { result = instance.asAlg().getEllipticCurveType() }
23462344

23472345
override predicate properties(string key, string value, Location location) {
23482346
super.properties(key, value, location)

0 commit comments

Comments
 (0)