Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inadequate scalar reduction in p384 leads to panic #312

Closed
guidovranken opened this issue Jan 24, 2022 · 1 comment · Fixed by #315
Closed

Inadequate scalar reduction in p384 leads to panic #312

guidovranken opened this issue Jan 24, 2022 · 1 comment · Fixed by #315
Assignees
Labels
bug Something isn't working

Comments

@guidovranken
Copy link

// reduceScalar shorten a scalar modulo the order of the curve.

reduceScalar is supposed to "shorten a scalar modulo the order of the curve" but it doesn't do that for all inputs and this can lead to a panic in wnaf.go.

PoC:

package main

import (
    "github.com/cloudflare/circl/ecc/p384"
    "math/big"
)

func main() {
    a_x, _ := new(big.Int).SetString("2197194086093689212280862101867524553402030273258457080984175289262818302155461584526794911762464589043284585654550", 10)
    a_y, _ := new(big.Int).SetString("27340319491623798325691320370638865713982009585794110374349453846146179674941474386159930807215381526124834607054138", 10)
    b, _ := new(big.Int).SetString("39402006196394479212279040100143613805079739270465446667946905279627659399113263569398956308152294913554433653942684", 10)

    curve := p384.P384()
    curve.ScalarMult(a_x, a_y, b.Bytes())
}
@armfazh armfazh self-assigned this Jan 24, 2022
@armfazh armfazh added the bug Something isn't working label Jan 24, 2022
@armfazh
Copy link
Contributor

armfazh commented Jan 24, 2022

Thanks for reporting @guidovranken , we will investigate the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants