Skip to content

Commit 12b7a0e

Browse files
committed
add ignore int to uint
1 parent 49ef319 commit 12b7a0e

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

crypto/elliptic/ed25519prue/edwards25519/field/fe.go

+2
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ func (v *Element) bytes(out *[32]byte) []byte {
236236
var buf [8]byte
237237
for i, l := range [5]uint64{t.l0, t.l1, t.l2, t.l3, t.l4} {
238238
bitsOffset := i * 51
239+
// #nosec: G115: integer overflow conversion uint64 -> uint
239240
byteorder.LePutUint64(buf[:], l<<uint(bitsOffset%8))
240241
for i, bb := range buf {
241242
off := bitsOffset/8 + i
@@ -256,6 +257,7 @@ func (v *Element) Equal(u *Element) int {
256257
}
257258

258259
// mask64Bits returns 0xffffffff if cond is 1, and 0 otherwise.
260+
// #nosec: G115: integer overflow conversion uint64 -> uint64
259261
func mask64Bits(cond int) uint64 { return ^(uint64(cond) - 1) }
260262

261263
// Select sets v to a if cond == 1, and to b if cond == 0.

crypto/elliptic/ed25519prue/edwards25519/scalar.go

+2
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,11 @@ func (s *Scalar) nonAdjacentForm(w uint) [256]int8 {
309309

310310
if window < width/2 {
311311
carry = 0
312+
// #nosec: G115: integer overflow conversion uint64 -> int8
312313
naf[pos] = int8(window)
313314
} else {
314315
carry = 1
316+
// #nosec: G115: integer overflow conversion uint64 -> int8
315317
naf[pos] = int8(window) - int8(width)
316318
}
317319

crypto/elliptic/ed25519prue/edwards25519/tables.go

+4
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ func (v *nafLookupTable8) FromP3(q *Point) {
9090
func (v *projLookupTable) SelectInto(dest *projCached, x int8) {
9191
// Compute xabs = |x|
9292
xmask := x >> 7
93+
// #nosec: G115: integer overflow conversion uint64 -> int8
9394
xabs := uint8((x + xmask) ^ xmask)
9495

9596
dest.Zero()
9697
for j := 1; j <= 8; j++ {
9798
// Set dest = j*Q if |x| = j
99+
// #nosec: G115: integer overflow conversion uint64 -> int8
98100
cond := subtle.ConstantTimeByteEq(xabs, uint8(j))
99101
dest.Select(&v.points[j-1], dest, cond)
100102
}
@@ -106,11 +108,13 @@ func (v *projLookupTable) SelectInto(dest *projCached, x int8) {
106108
func (v *affineLookupTable) SelectInto(dest *affineCached, x int8) {
107109
// Compute xabs = |x|
108110
xmask := x >> 7
111+
// #nosec: G115: integer overflow conversion uint64 -> int8
109112
xabs := uint8((x + xmask) ^ xmask)
110113

111114
dest.Zero()
112115
for j := 1; j <= 8; j++ {
113116
// Set dest = j*Q if |x| = j
117+
// #nosec: G115: integer overflow conversion uint64 -> int8
114118
cond := subtle.ConstantTimeByteEq(xabs, uint8(j))
115119
dest.Select(&v.points[j-1], dest, cond)
116120
}

0 commit comments

Comments
 (0)