package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type PasswordKdfAlgoUnknown struct {
}
const PasswordKdfAlgoUnknownTypeID = 0xd45ab096
func (p PasswordKdfAlgoUnknown ) construct () PasswordKdfAlgoClass { return &p }
var (
_ bin .Encoder = &PasswordKdfAlgoUnknown {}
_ bin .Decoder = &PasswordKdfAlgoUnknown {}
_ bin .BareEncoder = &PasswordKdfAlgoUnknown {}
_ bin .BareDecoder = &PasswordKdfAlgoUnknown {}
_ PasswordKdfAlgoClass = &PasswordKdfAlgoUnknown {}
)
func (p *PasswordKdfAlgoUnknown ) Zero () bool {
if p == nil {
return true
}
return true
}
func (p *PasswordKdfAlgoUnknown ) String () string {
if p == nil {
return "PasswordKdfAlgoUnknown(nil)"
}
type Alias PasswordKdfAlgoUnknown
return fmt .Sprintf ("PasswordKdfAlgoUnknown%+v" , Alias (*p ))
}
func (*PasswordKdfAlgoUnknown ) TypeID () uint32 {
return PasswordKdfAlgoUnknownTypeID
}
func (*PasswordKdfAlgoUnknown ) TypeName () string {
return "passwordKdfAlgoUnknown"
}
func (p *PasswordKdfAlgoUnknown ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "passwordKdfAlgoUnknown" ,
ID : PasswordKdfAlgoUnknownTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (p *PasswordKdfAlgoUnknown ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode passwordKdfAlgoUnknown#d45ab096 as nil" )
}
b .PutID (PasswordKdfAlgoUnknownTypeID )
return p .EncodeBare (b )
}
func (p *PasswordKdfAlgoUnknown ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode passwordKdfAlgoUnknown#d45ab096 as nil" )
}
return nil
}
func (p *PasswordKdfAlgoUnknown ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode passwordKdfAlgoUnknown#d45ab096 to nil" )
}
if err := b .ConsumeID (PasswordKdfAlgoUnknownTypeID ); err != nil {
return fmt .Errorf ("unable to decode passwordKdfAlgoUnknown#d45ab096: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PasswordKdfAlgoUnknown ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode passwordKdfAlgoUnknown#d45ab096 to nil" )
}
return nil
}
type PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow struct {
Salt1 []byte
Salt2 []byte
G int
P []byte
}
const PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID = 0x3a912d4a
func (p PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) construct () PasswordKdfAlgoClass {
return &p
}
var (
_ bin .Encoder = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow {}
_ bin .Decoder = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow {}
_ bin .BareEncoder = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow {}
_ bin .BareDecoder = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow {}
_ PasswordKdfAlgoClass = &PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow {}
)
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) Zero () bool {
if p == nil {
return true
}
if !(p .Salt1 == nil ) {
return false
}
if !(p .Salt2 == nil ) {
return false
}
if !(p .G == 0 ) {
return false
}
if !(p .P == nil ) {
return false
}
return true
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) String () string {
if p == nil {
return "PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow(nil)"
}
type Alias PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow
return fmt .Sprintf ("PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow%+v" , Alias (*p ))
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) FillFrom (from interface {
GetSalt1 () (value []byte )
GetSalt2 () (value []byte )
GetG () (value int )
GetP () (value []byte )
}) {
p .Salt1 = from .GetSalt1 ()
p .Salt2 = from .GetSalt2 ()
p .G = from .GetG ()
p .P = from .GetP ()
}
func (*PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) TypeID () uint32 {
return PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID
}
func (*PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) TypeName () string {
return "passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow"
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow" ,
ID : PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Salt1" ,
SchemaName : "salt1" ,
},
{
Name : "Salt2" ,
SchemaName : "salt2" ,
},
{
Name : "G" ,
SchemaName : "g" ,
},
{
Name : "P" ,
SchemaName : "p" ,
},
}
return typ
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a as nil" )
}
b .PutID (PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID )
return p .EncodeBare (b )
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a as nil" )
}
b .PutBytes (p .Salt1 )
b .PutBytes (p .Salt2 )
b .PutInt (p .G )
b .PutBytes (p .P )
return nil
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a to nil" )
}
if err := b .ConsumeID (PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID ); err != nil {
return fmt .Errorf ("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a to nil" )
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: field salt1: %w" , err )
}
p .Salt1 = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: field salt2: %w" , err )
}
p .Salt2 = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: field g: %w" , err )
}
p .G = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow#3a912d4a: field p: %w" , err )
}
p .P = value
}
return nil
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) GetSalt1 () (value []byte ) {
if p == nil {
return
}
return p .Salt1
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) GetSalt2 () (value []byte ) {
if p == nil {
return
}
return p .Salt2
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) GetG () (value int ) {
if p == nil {
return
}
return p .G
}
func (p *PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ) GetP () (value []byte ) {
if p == nil {
return
}
return p .P
}
const PasswordKdfAlgoClassName = "PasswordKdfAlgo"
type PasswordKdfAlgoClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PasswordKdfAlgoClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodePasswordKdfAlgo (buf *bin .Buffer ) (PasswordKdfAlgoClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PasswordKdfAlgoUnknownTypeID :
v := PasswordKdfAlgoUnknown {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PasswordKdfAlgoClass: %w" , err )
}
return &v , nil
case PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPowTypeID :
v := PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PasswordKdfAlgoClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode PasswordKdfAlgoClass: %w" , bin .NewUnexpectedID (id ))
}
}
type PasswordKdfAlgoBox struct {
PasswordKdfAlgo PasswordKdfAlgoClass
}
func (b *PasswordKdfAlgoBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode PasswordKdfAlgoBox to nil" )
}
v , err := DecodePasswordKdfAlgo (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .PasswordKdfAlgo = v
return nil
}
func (b *PasswordKdfAlgoBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .PasswordKdfAlgo == nil {
return fmt .Errorf ("unable to encode PasswordKdfAlgoClass as nil" )
}
return b .PasswordKdfAlgo .Encode (buf )
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .