func NewPubkey(op *packet.OpaquePacket) (pubkey *Pubkey, err error) { var buf bytes.Buffer if err = op.Serialize(&buf); err != nil { return } pubkey = &Pubkey{Packet: buf.Bytes()} var p packet.Packet if p, err = op.Parse(); err != nil { return pubkey, pubkey.initUnsupported(op) } if err = pubkey.setPacket(p); err != nil { return } if pubkey.PublicKey != nil { err = pubkey.initV4() } else if pubkey.PublicKeyV3 != nil { err = pubkey.initV3() } else { err = ErrInvalidPacketType } if err != nil { pubkey.PublicKey = nil pubkey.PublicKeyV3 = nil return pubkey, pubkey.initUnsupported(op) } return }
func NewUserId(op *packet.OpaquePacket) (uid *UserId, err error) { var buf bytes.Buffer if err = op.Serialize(&buf); err != nil { return } uid = &UserId{Packet: buf.Bytes()} var p packet.Packet if p, err = op.Parse(); err != nil { return } if err = uid.setPacket(p); err != nil { return } return uid, uid.init() }
func NewUserAttribute(op *packet.OpaquePacket) (uat *UserAttribute, err error) { var buf bytes.Buffer if err = op.Serialize(&buf); err != nil { return } uat = &UserAttribute{Packet: buf.Bytes()} var p packet.Packet if p, err = op.Parse(); err != nil { return } if err = uat.setPacket(p); err != nil { return } return uat, uat.init() }
func NewSubkey(op *packet.OpaquePacket) (subkey *Subkey, err error) { var buf bytes.Buffer if err = op.Serialize(&buf); err != nil { return } subkey = &Subkey{Packet: buf.Bytes()} var p packet.Packet if p, err = op.Parse(); err != nil { return } if err = subkey.setPacket(p); err != nil { return } if subkey.PublicKey != nil { err = subkey.initV4() } else if subkey.PublicKeyV3 != nil { err = subkey.initV3() } else { err = ErrInvalidPacketType } return }
func NewSignature(op *packet.OpaquePacket) (sig *Signature, err error) { var buf bytes.Buffer if err = op.Serialize(&buf); err != nil { return } sig = &Signature{Packet: buf.Bytes()} var p packet.Packet if p, err = op.Parse(); err != nil { return } if err = sig.setPacket(p); err != nil { return } if sig.Signature != nil { err = sig.initV4() } else if sig.SignatureV3 != nil { err = sig.initV3() } else { err = ErrInvalidPacketType } return }
func (pubkey *Pubkey) AppendUnsupported(opkt *packet.OpaquePacket) { var buf bytes.Buffer opkt.Serialize(&buf) pubkey.Unsupported = append(pubkey.Unsupported, buf.Bytes()...) }