@@ -39,6 +39,7 @@ import (
39
39
"github.com/smallstep/certificates/acme/wire"
40
40
"github.com/smallstep/certificates/authority/provisioner"
41
41
wireprovisioner "github.com/smallstep/certificates/authority/provisioner/wire"
42
+ "github.com/smallstep/certificates/internal/cast"
42
43
)
43
44
44
45
type ChallengeType string
@@ -229,7 +230,7 @@ func tlsAlert(err error) uint8 {
229
230
if errors .As (err , & opErr ) {
230
231
v := reflect .ValueOf (opErr .Err )
231
232
if v .Kind () == reflect .Uint8 {
232
- return uint8 (v .Uint ())
233
+ return uint8 (v .Uint ()) //nolint:gosec // handled by checking its type
233
234
}
234
235
}
235
236
return 0
@@ -978,9 +979,9 @@ type tpmAttestationData struct {
978
979
type coseAlgorithmIdentifier int32
979
980
980
981
const (
981
- coseAlgES256 coseAlgorithmIdentifier = - 7
982
- coseAlgRS256 coseAlgorithmIdentifier = - 257
983
- coseAlgRS1 coseAlgorithmIdentifier = - 65535 // deprecated, but (still) often used in TPMs
982
+ coseAlgES256 = coseAlgorithmIdentifier ( - 7 )
983
+ coseAlgRS256 = coseAlgorithmIdentifier ( - 257 )
984
+ coseAlgRS1 = coseAlgorithmIdentifier ( - 65535 ) // deprecated, but (still) often used in TPMs
984
985
)
985
986
986
987
func doTPMAttestationFormat (_ context.Context , prov Provisioner , ch * Challenge , jwk * jose.JSONWebKey , att * attestationObject ) (* tpmAttestationData , error ) {
@@ -1105,8 +1106,13 @@ func doTPMAttestationFormat(_ context.Context, prov Provisioner, ch *Challenge,
1105
1106
return nil , NewDetailedError (ErrorBadAttestationStatementType , "invalid alg in attestation statement" )
1106
1107
}
1107
1108
1109
+ algI32 , err := cast .SafeInt32 (alg )
1110
+ if err != nil {
1111
+ return nil , WrapDetailedError (ErrorBadAttestationStatementType , err , "invalid alg %d in attestation statement" , alg )
1112
+ }
1113
+
1108
1114
var hash crypto.Hash
1109
- switch coseAlgorithmIdentifier (alg ) {
1115
+ switch coseAlgorithmIdentifier (algI32 ) {
1110
1116
case coseAlgRS256 , coseAlgES256 :
1111
1117
hash = crypto .SHA256
1112
1118
case coseAlgRS1 :
0 commit comments