@@ -51,7 +51,9 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
5151 * This predicate is used by derived classes to construct the graph of cryptographic operations.
5252 */
5353 predicate properties ( string key , string value , Location location ) {
54- key = "origin" and location = this .getOrigin ( value ) .getLocation ( )
54+ key = "origin" and
55+ location = this .getOrigin ( value ) .getLocation ( ) and
56+ not location = this .getLocation ( )
5557 }
5658
5759 /**
@@ -92,6 +94,11 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
9294 */
9395 abstract string getAlgorithmName ( ) ;
9496
97+ /**
98+ * Gets the raw name of this algorithm from source (no parsing or formatting)
99+ */
100+ abstract string getRawAlgorithmName ( ) ;
101+
95102 final override string toString ( ) { result = this .getAlgorithmName ( ) }
96103 }
97104
@@ -145,10 +152,6 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
145152
146153 override string getAlgorithmName ( ) { this .hashTypeToNameMapping ( this .getHashType ( ) , result ) }
147154
148- /**
149- * Gets the raw name of this hash algorithm from source.
150- */
151- abstract string getRawAlgorithmName ( ) ;
152155 }
153156
154157 /**
@@ -195,30 +198,55 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
195198 }
196199 }
197200
201+ newtype TEllipticCurveFamilyType =
202+ // We're saying by this that all of these have an identical interface / properties / edges
203+ NIST ( ) or
204+ SEC ( ) or
205+ NUMS ( ) or
206+ PRIME ( ) or
207+ BRAINPOOL ( ) or
208+ CURVE25519 ( ) or
209+ CURVE448 ( ) or
210+ C2 ( ) or
211+ SM2 ( ) or
212+ ES ( ) or
213+ OtherEllipticCurveFamilyType ( )
214+
215+
198216 /**
199217 * Elliptic curve algorithm
200218 */
201219 abstract class EllipticCurve extends Algorithm {
202- abstract string getVersion ( Location location ) ;
220+
203221
204222 abstract string getKeySize ( Location location ) ;
205223
224+ abstract TEllipticCurveFamilyType getCurveFamilyType ( ) ;
225+
206226 override predicate properties ( string key , string value , Location location ) {
207227 super .properties ( key , value , location )
208228 or
209- key = "version" and
210- if exists ( this .getVersion ( location ) )
211- then value = this .getVersion ( location )
212- else (
213- value instanceof UnknownPropertyValue and location instanceof UnknownLocation
214- )
215- or
216229 key = "key_size" and
217230 if exists ( this .getKeySize ( location ) )
218231 then value = this .getKeySize ( location )
219232 else (
220233 value instanceof UnknownPropertyValue and location instanceof UnknownLocation
221234 )
235+ // other properties, like field type are possible, but not modeled until considered necessary
222236 }
237+
238+ override string getAlgorithmName ( ) { result = this .getRawAlgorithmName ( ) .toUpperCase ( ) }
239+
240+ /**
241+ * Mandating that for Elliptic Curves specifically, users are responsible
242+ * for providing as the 'raw' name, the official name of the algorithm.
243+ * Casing doesn't matter, we will enforce further naming restrictions on
244+ * `getAlgorithmName` by default.
245+ * Rationale: elliptic curve names can have a lot of variation in their components
246+ * (e.g., "secp256r1" vs "P-256"), trying to produce generalized set of properties
247+ * is possible to capture all cases, but such modeling is likely not necessary.
248+ * if all properties need to be captured, we can reassess how names are generated.
249+ */
250+ override abstract string getRawAlgorithmName ( ) ;
223251 }
224252}
0 commit comments