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
while True: | |
get_context().precision = self.limit_precision(precision) | |
attempts += 1 | |
testPrefix = prefix + urandom(self.keysize_bytes - len(prefix)) | |
signatureCandidate = ( | |
toBytes( | |
self.nthroot( | |
self.public_exponent, | |
toInt(testPrefix), | |
self.limit_precision(precision), |
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
def encodePkcs1Suffix(self, message): | |
messageHash = self.hashAlg.digester(message.encode("utf-8")).digest() | |
if messageHash[-1] & 0x01 != 0x01: | |
print( | |
"Hash value must be uneven. Try a different message or a different | |
hash algorithm", | |
file=stderr, | |
) | |
exit(1) | |
suffix = bytes([0]) + self.hashAlg.digestInfo + messageHash |
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
sequence = DerSequence() | |
sequence.decode(_digest_algorithm_identifier) | |
_digest_algorithm_identifier = sequence[0] | |
object_id = DerObjectId() | |
object_id.decode(_digest_algorithm_identifier) | |
digest_algorithm_identifier = object_id.value | |
if digest_algorithm_identifier != '2.16.840.1.101.3.4.2.1': | |
raise Exception('invalid digest algorithm identifier') |
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
def verify(self, m, s): | |
if len(s) != self.bits//8: | |
raise Exception('incorrect signature length') | |
s = int.from_bytes(s, 'big') | |
k = pow(s, self.e, self.n) | |
k = int.to_bytes(k, self.bits//8, 'big') | |
if k[0] != 0x00: | |
raise Exception('incorrect prefix') |
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
#!/bin/sh | |
python Forge.py -q | |
-of hex \ | |
-k 2048 \ | |
-va 1 \ | |
-ha SHA-256 \ | |
-m "[\"pzero-adventures\", \"aaa\", -1]" |
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
package main | |
import ( | |
"archive/tar" | |
"compress/gzip" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"net/http" | |
"os" |
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
import java.security.MessageDigest; | |
import java.util.Random; | |
import java.util.Base64; | |
import java.util.Locale; | |
import java.util.Date; | |
import javax.crypto.spec.SecretKeySpec; | |
import javax.crypto.Mac; | |
import java.nio.charset.StandardCharsets; | |
import java.nio.charset.Charset; |
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
#!/bin/sh | |
PORTS=`ls /dev/cu*USB* 2> /dev/null` | |
if [ $? -eq 1 ]; then | |
PORTS=`ls /dev/cu*usb* 2> /dev/null` | |
if [ $? -eq 1 ]; then | |
echo "No USB serial port found." | |
exit 1 | |
fi | |
fi |
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
type FullBufferReader struct{ reader *io.Reader } | |
func (br *FullBufferReader) Read(p []byte) (int, error) { | |
n, err := io.ReadFull(*br.reader, p) | |
if err != nil { | |
if err == io.ErrUnexpectedEOF { | |
return n, io.EOF | |
} else { | |
return n, err |
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
package util | |
import ( | |
"io" | |
) | |
type LinePipe struct { | |
leftover []byte | |
scanner TextScanner | |
bytesWritten int |
NewerOlder