-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into namespace-kas-grants
- Loading branch information
Showing
22 changed files
with
930 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
docs/openapi/policy/resourcemapping/resource_mapping.swagger.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package ocrypto | ||
|
||
import ( | ||
"crypto/elliptic" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func makeCompressedZeroSeed(l int) []byte { | ||
seed := make([]byte, l) | ||
seed[0] = 3 | ||
return seed | ||
} | ||
|
||
func makeCompressedRandomSeed(f *testing.F, mode ECCMode) []byte { | ||
curve, err := GetECCurveFromECCMode(mode) | ||
require.NoError(f, err) | ||
keyPair, err := NewECKeyPair(mode) | ||
require.NoError(f, err) | ||
pubKey := keyPair.PrivateKey.PublicKey | ||
|
||
return elliptic.MarshalCompressed(curve, pubKey.X, pubKey.Y) | ||
} | ||
|
||
func FuzzUncompressECPubKey(f *testing.F) { | ||
// real random key examples | ||
f.Add(makeCompressedRandomSeed(f, ECCModeSecp256r1)) | ||
f.Add(makeCompressedRandomSeed(f, ECCModeSecp384r1)) | ||
f.Add(makeCompressedRandomSeed(f, ECCModeSecp521r1)) | ||
// zero examples | ||
f.Add(makeCompressedZeroSeed(curveByteLength(elliptic.P224()))) | ||
f.Add(makeCompressedZeroSeed(curveByteLength(elliptic.P256()))) | ||
f.Add(makeCompressedZeroSeed(curveByteLength(elliptic.P384()))) | ||
f.Add(makeCompressedZeroSeed(curveByteLength(elliptic.P521()))) | ||
|
||
f.Fuzz(func(t *testing.T, data []byte) { | ||
curve := elliptic.P256() | ||
switch len(data) { // check if other curves are a better fit | ||
case curveByteLength(elliptic.P224()): | ||
curve = elliptic.P224() | ||
case curveByteLength(elliptic.P384()): | ||
curve = elliptic.P384() | ||
case curveByteLength(elliptic.P521()): | ||
curve = elliptic.P521() | ||
} | ||
|
||
require.NotPanics(t, func() { | ||
_, _ = UncompressECPubKey(curve, data) | ||
}) | ||
}) | ||
} | ||
|
||
func curveByteLength(curve elliptic.Curve) int { | ||
return 1 + (curve.Params().BitSize+7)/8 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.