func NewIdentityKey(keytype int) (*IdentityKey, error) { var err error i := new(IdentityKey) switch keytype { case KEYRSA: i.keyType = keytype i.rsa, err = GenKeysRSA(rand.Reader) case KEYECDSA: i.keyType = keytype i.ecdsa, err = GenKeysECDSA(rand.Reader) //fmt.Printf("ECDSAAAAA: %v / %v\n", i.ecdsa, err) jsonProut, err := json.Marshal(i.ecdsa.Public()) jsonTa, err := json.Marshal(i.ecdsa) fmt.Printf("ERROR: %s\n", err) b64comp, err := acutl.CompressData(jsonProut) b64pub := acutl.B64EncodeData(b64comp) fmt.Printf("JSON PublicKey: %s\n", jsonProut) fmt.Printf("JSON PublicKey: ac-ecdsa %s\n", b64pub) fmt.Printf("JSON AllKey: %s\n", jsonTa) case KEYEC25519: i.keyType = keytype i.ec25519, err = GenKeysED25519(rand.Reader) default: err = errors.New("invalid type") return nil, err } fmt.Printf("C'EST BON ON A FINI\n") return i, nil }
func packMessageAC(hdr *uint32, nonce uint32, blob *[]byte) (out []byte, err error) { acOut := &ACPackedMessage{} acOut.Header = hdr acOut.Nonce = proto.Uint32(nonce) acOut.Ciphertext = *blob //acOut.Options = proto.Uint32(10034) //fmt.Printf("Nonce: %d(%08x)\n", nonce, nonce) acPackedMsg, err := proto.Marshal(acOut) if err != nil { return nil, err } // XXX test for errors message.. //fmt.Printf("AC Message TEST #1 : %d (%v)\n", len(acPackedMsg), err) //fmt.Printf("PACKED: %s\n", hex.EncodeToString(acPackedMsg)) out = acutl.B64EncodeData(acPackedMsg) return out, nil }