@@ -22,7 +22,7 @@ private module CryptographyModel {
22
22
* Gets a predefined curve class from
23
23
* `cryptography.hazmat.primitives.asymmetric.ec` with a specific key size (in bits).
24
24
*/
25
- private DataFlow :: Node curveClassWithKeySize ( int keySize ) {
25
+ private API :: Node predefinedCurveClass ( int keySize ) {
26
26
exists ( string curveName |
27
27
result =
28
28
API:: moduleImport ( "cryptography" )
@@ -31,7 +31,6 @@ private module CryptographyModel {
31
31
.getMember ( "asymmetric" )
32
32
.getMember ( "ec" )
33
33
.getMember ( curveName )
34
- .getAUse ( )
35
34
|
36
35
// obtained by manually looking at source code in
37
36
// https://github.com/pyca/cryptography/blob/cba69f1922803f4f29a3fde01741890d88b8e217/src/cryptography/hazmat/primitives/asymmetric/ec.py#L208-L300
@@ -75,13 +74,30 @@ private module CryptographyModel {
75
74
)
76
75
}
77
76
77
+ /** Gets a reference to a predefined curve class with a specific key size (in bits), as well as the origin of the class. */
78
+ private DataFlow:: LocalSourceNode curveClassWithKeySize (
79
+ DataFlow:: TypeTracker t , int keySize , DataFlow:: Node origin
80
+ ) {
81
+ t .start ( ) and
82
+ result = predefinedCurveClass ( keySize ) .getAnImmediateUse ( ) and
83
+ origin = result
84
+ or
85
+ exists ( DataFlow:: TypeTracker t2 |
86
+ result = curveClassWithKeySize ( t2 , keySize , origin ) .track ( t2 , t )
87
+ )
88
+ }
89
+
90
+ /** Gets a reference to a predefined curve class with a specific key size (in bits), as well as the origin of the class. */
91
+ DataFlow:: Node curveClassWithKeySize ( int keySize , DataFlow:: Node origin ) {
92
+ curveClassWithKeySize ( DataFlow:: TypeTracker:: end ( ) , keySize , origin ) .flowsTo ( result )
93
+ }
94
+
78
95
/** Gets a reference to a predefined curve class instance with a specific key size (in bits), as well as the origin of the class. */
79
96
private DataFlow:: LocalSourceNode curveClassInstanceWithKeySize (
80
97
DataFlow:: TypeTracker t , int keySize , DataFlow:: Node origin
81
98
) {
82
99
t .start ( ) and
83
- result .( DataFlow:: CallCfgNode ) .getFunction ( ) = curveClassWithKeySize ( keySize ) and
84
- origin = result
100
+ result .( DataFlow:: CallCfgNode ) .getFunction ( ) = curveClassWithKeySize ( keySize , origin )
85
101
or
86
102
exists ( DataFlow:: TypeTracker t2 |
87
103
result = curveClassInstanceWithKeySize ( t2 , keySize , origin ) .track ( t2 , t )
@@ -164,6 +180,8 @@ private module CryptographyModel {
164
180
165
181
override int getKeySizeWithOrigin ( DataFlow:: Node origin ) {
166
182
this .getCurveArg ( ) = Ecc:: curveClassInstanceWithKeySize ( result , origin )
183
+ or
184
+ this .getCurveArg ( ) = Ecc:: curveClassWithKeySize ( result , origin )
167
185
}
168
186
169
187
// Note: There is not really a key-size argument, since it's always specified by the curve.
0 commit comments