-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package bbig | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/microsoft/go-crypto-winnative/cng" | ||
) | ||
|
||
func Enc(b *big.Int) cng.BigInt { | ||
if b == nil { | ||
return nil | ||
} | ||
x := b.Bytes() | ||
if len(x) == 0 { | ||
return cng.BigInt{} | ||
} | ||
return x | ||
} | ||
|
||
func Dec(b cng.BigInt) *big.Int { | ||
if b == nil { | ||
return nil | ||
} | ||
if len(b) == 0 { | ||
return new(big.Int) | ||
} | ||
return new(big.Int).SetBytes(b) | ||
} |
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,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
package cng | ||
|
||
// This file does not have build constraints to | ||
// facilitate using BigInt in Go crypto. | ||
// Go crypto references BigInt unconditionally, | ||
// even if it is not finally used. | ||
|
||
// A BigInt is the raw big-endian bytes from a BigInt. | ||
// This definition allows us to avoid importing math/big. | ||
// Conversion between BigInt and *big.Int is in cng/bbig. | ||
type BigInt []byte |
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