-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blocklist generator for SHA-256(Modulus) and SHA-256(XCoordinate) blo…
…cklists.
- Loading branch information
1 parent
1d57798
commit 431b8de
Showing
4 changed files
with
45 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# dwk_blocklist_generator | ||
Debian weak key blocklist generator | ||
|
||
``` bash | ||
go build | ||
``` |
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,3 @@ | ||
module github.com/CVE-2008-0166/key_generator/dwk_blocklist_generator | ||
|
||
go 1.21.6 |
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,35 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha256" | ||
"crypto/x509" | ||
"encoding/hex" | ||
"fmt" | ||
"log" | ||
"os" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) != 2 { | ||
log.Fatalf("Usage: %s <private_keys_directory>\n", os.Args[0]) | ||
} else if files, err := os.ReadDir(os.Args[1]); err != nil { | ||
log.Fatalf("os.ReadDir() => %v\n", err) | ||
} else { | ||
for _, file := range files { | ||
if !strings.HasSuffix(file.Name(), ".key") { | ||
continue | ||
} else if key, err := os.ReadFile(os.Args[1] + "/" + file.Name()); err != nil { | ||
log.Fatalf("os.ReadFile(%s) => %v\n", file.Name(), err) | ||
} else if rsakey, err := x509.ParsePKCS1PrivateKey(key); err == nil { | ||
sha256_modulus := sha256.Sum256(rsakey.N.Bytes()) | ||
fmt.Printf("%s\n", hex.EncodeToString(sha256_modulus[:])) | ||
} else if eckey, err2 := x509.ParseECPrivateKey(key); err2 == nil { | ||
sha256_xcoord := sha256.Sum256(eckey.X.Bytes()) | ||
fmt.Printf("%s\n", hex.EncodeToString(sha256_xcoord[:])) | ||
} else { | ||
log.Fatalf("%s: x509.ParsePKCS1PrivateKey() => %v; x509.ParseECPrivateKey() => %v\n", file.Name(), err, err2) | ||
} | ||
} | ||
} | ||
} |