2020-08-27 21:45:09 +00:00
|
|
|
//
|
|
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
|
|
//
|
|
|
|
// This is a commercial product and requires a license to operate.
|
|
|
|
// A trial license can be obtained at https://unidoc.io
|
|
|
|
//
|
|
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
|
|
|
|
2020-11-11 18:48:37 +00:00
|
|
|
package security ;import (_gcc "bytes";_ab "crypto/aes";_c "crypto/cipher";_fd "crypto/md5";_gd "crypto/rand";_bf "crypto/rc4";_b "crypto/sha256";_g "crypto/sha512";_f "encoding/binary";_gc "errors";_ba "fmt";_fbd "github.com/unidoc/unipdf/v3/common";_ac "hash";_a "io";_fb "math";);func _aa (_ff _c .Block )*ecb {return &ecb {_baa :_ff ,_acg :_ff .BlockSize ()}};
|
2020-10-05 19:28:24 +00:00
|
|
|
|
2020-10-19 10:58:10 +00:00
|
|
|
// StdEncryptDict is a set of additional fields used in standard encryption dictionary.
|
2020-11-11 18:48:37 +00:00
|
|
|
type StdEncryptDict struct{R int ;P Permissions ;EncryptMetadata bool ;O ,U []byte ;OE ,UE []byte ;Perms []byte ;};func (_abc stdHandlerR6 )alg2b (R int ,_bfe ,_acdg ,_fba []byte )([]byte ,error ){if R ==5{return _be (_bfe );};return _ccd (_bfe ,_acdg ,_fba );};
|
2020-09-07 00:23:12 +00:00
|
|
|
|
2020-09-28 23:18:17 +00:00
|
|
|
// StdHandler is an interface for standard security handlers.
|
|
|
|
type StdHandler interface{
|
2020-09-21 01:20:10 +00:00
|
|
|
|
2020-09-28 23:18:17 +00:00
|
|
|
// GenerateParams uses owner and user passwords to set encryption parameters and generate an encryption key.
|
|
|
|
// It assumes that R, P and EncryptMetadata are already set.
|
2020-11-11 18:48:37 +00:00
|
|
|
GenerateParams (_ed *StdEncryptDict ,_dg ,_da []byte )([]byte ,error );
|
2020-09-21 01:20:10 +00:00
|
|
|
|
2020-09-28 23:18:17 +00:00
|
|
|
// Authenticate uses encryption dictionary parameters and the password to calculate
|
|
|
|
// the document encryption key. It also returns permissions that should be granted to a user.
|
|
|
|
// In case of failed authentication, it returns empty key and zero permissions with no error.
|
2020-11-11 18:48:37 +00:00
|
|
|
Authenticate (_bg *StdEncryptDict ,_aee []byte )([]byte ,Permissions ,error );};type stdHandlerR4 struct{Length int ;ID0 string ;};func (_ebe stdHandlerR6 )alg8 (_bba *StdEncryptDict ,_deb []byte ,_bea []byte )error {if _ddag :=_dd ("\u0061\u006c\u0067\u0038","\u004b\u0065\u0079",32,_deb );_ddag !=nil {return _ddag ;};var _cfed [16]byte ;if _ ,_bfga :=_a .ReadFull (_gd .Reader ,_cfed [:]);_bfga !=nil {return _bfga ;};_cdgd :=_cfed [0:8];_afb :=_cfed [8:16];_fbe :=make ([]byte ,len (_bea )+len (_cdgd ));_bae :=copy (_fbe ,_bea );copy (_fbe [_bae :],_cdgd );_cggd ,_gcbg :=_ebe .alg2b (_bba .R ,_fbe ,_bea ,nil );if _gcbg !=nil {return _gcbg ;};U :=make ([]byte ,len (_cggd )+len (_cdgd )+len (_afb ));_bae =copy (U ,_cggd [:32]);_bae +=copy (U [_bae :],_cdgd );copy (U [_bae :],_afb );_bba .U =U ;_bae =len (_bea );copy (_fbe [_bae :],_afb );_cggd ,_gcbg =_ebe .alg2b (_bba .R ,_fbe ,_bea ,nil );if _gcbg !=nil {return _gcbg ;};_faff ,_gcbg :=_gad (_cggd [:32]);if _gcbg !=nil {return _gcbg ;};_dcd :=make ([]byte ,_ab .BlockSize );_fcc :=_c .NewCBCEncrypter (_faff ,_dcd );UE :=make ([]byte ,32);_fcc .CryptBlocks (UE ,_deb [:32]);_bba .UE =UE ;return nil ;};type stdHandlerR6 struct{};func _dd (_fe ,_dac string ,_fdg int ,_dc []byte )error {if len (_dc )< _fdg {return errInvalidField {Func :_fe ,Field :_dac ,Exp :_fdg ,Got :len (_dc )};};return nil ;};
|
2020-10-19 10:58:10 +00:00
|
|
|
|
|
|
|
// Permissions is a bitmask of access permissions for a PDF file.
|
2020-11-11 18:48:37 +00:00
|
|
|
type Permissions uint32 ;const _fa ="\x28\277\116\136\x4e\x75\x8a\x41\x64\000\x4e\x56\377"+"\xfa\001\010\056\x2e\x00\xb6\xd0\x68\076\x80\x2f\014"+"\251\xfe\x64\x53\x69\172";func (_ae *ecbDecrypter )BlockSize ()int {return _ae ._acg };
|
2020-09-28 23:18:17 +00:00
|
|
|
|
2020-10-05 19:28:24 +00:00
|
|
|
// NewHandlerR6 creates a new standard security handler for R=5 and R=6.
|
2020-11-11 18:48:37 +00:00
|
|
|
func NewHandlerR6 ()StdHandler {return stdHandlerR6 {}};
|
|
|
|
|
|
|
|
// NewHandlerR4 creates a new standard security handler for R<=4.
|
|
|
|
func NewHandlerR4 (id0 string ,length int )StdHandler {return stdHandlerR4 {ID0 :id0 ,Length :length }};func _df (_ad _c .Block )_c .BlockMode {return (*ecbEncrypter )(_aa (_ad ))};func (_ee stdHandlerR4 )alg3Key (R int ,_dab []byte )[]byte {_faf :=_fd .New ();_aed :=_ee .paddedPass (_dab );_faf .Write (_aed );if R >=3{for _ca :=0;_ca < 50;_ca ++{_cc :=_faf .Sum (nil );_faf =_fd .New ();_faf .Write (_cc );};};_fff :=_faf .Sum (nil );if R ==2{_fff =_fff [0:5];}else {_fff =_fff [0:_ee .Length /8];};return _fff ;};type ecb struct{_baa _c .Block ;_acg int ;};func (_ccf stdHandlerR6 )alg13 (_aba *StdEncryptDict ,_ffg []byte )error {if _bcga :=_dd ("\u0061\u006c\u00671\u0033","\u004b\u0065\u0079",32,_ffg );_bcga !=nil {return _bcga ;};if _agaf :=_dd ("\u0061\u006c\u00671\u0033","\u0050\u0065\u0072m\u0073",16,_aba .Perms );_agaf !=nil {return _agaf ;};_dgfd :=make ([]byte ,16);copy (_dgfd ,_aba .Perms [:16]);_bbag ,_fea :=_ab .NewCipher (_ffg [:32]);if _fea !=nil {return _fea ;};_bbac :=_e (_bbag );_bbac .CryptBlocks (_dgfd ,_dgfd );if !_gcc .Equal (_dgfd [9:12],[]byte ("\u0061\u0064\u0062")){return _gc .New ("\u0064\u0065\u0063o\u0064\u0065\u0064\u0020p\u0065\u0072\u006d\u0069\u0073\u0073\u0069o\u006e\u0073\u0020\u0061\u0072\u0065\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064");};_fffa :=Permissions (_f .LittleEndian .Uint32 (_dgfd [0:4]));if _fffa !=_aba .P {return _gc .New ("\u0070\u0065r\u006d\u0069\u0073\u0073\u0069\u006f\u006e\u0073\u0020\u0076\u0061\u006c\u0069\u0064\u0061\u0074\u0069\u006f\u006e\u0020\u0066\u0061il\u0065\u0064");};var _dfa bool ;if _dgfd [8]=='T'{_dfa =true ;}else if _dgfd [8]=='F'{_dfa =false ;}else {return _gc .New ("\u0064\u0065\u0063\u006f\u0064\u0065\u0064 \u006d\u0065\u0074a\u0064\u0061\u0074\u0061 \u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0069\u006f\u006e\u0020\u0066\u006c\u0061\u0067\u0020\u0069\u0073\u0020\u0069\u006e\u0076\u0061\u006c\u0069\u0064");};if _dfa !=_aba .EncryptMetadata {return _gc .New ("\u006d\u0065t\u0061\u0064\u0061\u0074a\u0020\u0065n\u0063\u0072\u0079\u0070\u0074\u0069\u006f\u006e \u0076\u0061\u006c\u0069\u0064\u0061\u0074\u0069\u006f\u006e\u0020\u0066a\u0069\u006c\u0065\u0064");};return nil ;};
|
2020-09-28 23:18:17 +00:00
|
|
|
|
2020-10-12 14:17:59 +00:00
|
|
|
// GenerateParams is the algorithm opposite to alg2a (R>=5).
|
|
|
|
// It generates U,O,UE,OE,Perms fields using AESv3 encryption.
|
|
|
|
// There is no algorithm number assigned to this function in the spec.
|
|
|
|
// It expects R, P and EncryptMetadata fields to be set.
|
2020-11-11 18:48:37 +00:00
|
|
|
func (_fffad stdHandlerR6 )GenerateParams (d *StdEncryptDict ,opass ,upass []byte )([]byte ,error ){_abcc :=make ([]byte ,32);if _ ,_aeea :=_a .ReadFull (_gd .Reader ,_abcc );_aeea !=nil {return nil ,_aeea ;};d .U =nil ;d .O =nil ;d .UE =nil ;d .OE =nil ;d .Perms =nil ;if len (upass )> 127{upass =upass [:127];};if len (opass )> 127{opass =opass [:127];};if _gcga :=_fffad .alg8 (d ,_abcc ,upass );_gcga !=nil {return nil ,_gcga ;};if _bbae :=_fffad .alg9 (d ,_abcc ,opass );_bbae !=nil {return nil ,_bbae ;};if d .R ==5{return _abcc ,nil ;};if _eddg :=_fffad .alg10 (d ,_abcc );_eddg !=nil {return nil ,_eddg ;};return _abcc ,nil ;};func (_fbg stdHandlerR4 )alg5 (_ddc []byte ,_acgg []byte )([]byte ,error ){_agc :=_fd .New ();_agc .Write ([]byte (_fa ));_agc .Write ([]byte (_fbg .ID0 ));_ea :=_agc .Sum (nil );_fbd .Log .Trace ("\u0061\u006c\u0067\u0035");_fbd .Log .Trace ("\u0065k\u0065\u0079\u003a\u0020\u0025\u0020x",_ddc );_fbd .Log .Trace ("\u0049D\u003a\u0020\u0025\u0020\u0078",_fbg .ID0 );if len (_ea )!=16{return nil ,_gc .New ("\u0068a\u0073\u0068\u0020\u006c\u0065\u006e\u0067\u0074\u0068\u0020\u006eo\u0074\u0020\u0031\u0036\u0020\u0062\u0079\u0074\u0065\u0073");};_fc ,_dce :=_bf .NewCipher (_ddc );if _dce !=nil {return nil ,_gc .New ("\u0066a\u0069l\u0065\u0064\u0020\u0072\u0063\u0034\u0020\u0063\u0069\u0070\u0068");};_cd :=make ([]byte ,16);_fc .XORKeyStream (_cd ,_ea );_baf :=make ([]byte ,len (_ddc ));for _cab :=0;_cab < 19;_cab ++{for _dgf :=0;_dgf < len (_ddc );_dgf ++{_baf [_dgf ]=_ddc [_dgf ]^byte (_cab +1);};_fc ,_dce =_bf .NewCipher (_baf );if _dce !=nil {return nil ,_gc .New ("\u0066a\u0069l\u0065\u0064\u0020\u0072\u0063\u0034\u0020\u0063\u0069\u0070\u0068");};_fc .XORKeyStream (_cd ,_cd );_fbd .Log .Trace ("\u0069\u0020\u003d\u0020\u0025\u0064\u002c\u0020\u0065\u006b\u0065\u0079:\u0020\u0025\u0020\u0078",_cab ,_baf );_fbd .Log .Trace ("\u0069\u0020\u003d\u0020\u0025\u0064\u0020\u002d\u003e\u0020\u0025\u0020\u0078",_cab ,_cd );};_fg :=make ([]byte ,32);for _fdb :=0;_fdb < 16;_fdb ++{_fg [_fdb ]=_cd [_fdb ];};_ ,_dce =_gd .Read (_fg [16:32]);if _dce !=nil {return nil ,_gc .New ("\u0066a\u0069\u006c\u0065\u0064 \u0074\u006f\u0020\u0067\u0065n\u0020r\u0061n\u0064\u0020\u006e\u0075\u006d\u0062\u0065r");};return _fg ,nil ;};func (_ge stdHandlerR4 )alg2 (_db *StdEncryptDict ,_cb []byte )[]byte {_fbd .Log .Trace ("\u0061\u006c\u0067\u0032");_eb :=_ge .paddedPass (_cb );_dbf :=_fd .New ();_dbf .Write (_eb );_dbf .Write (_db .O );var _bgb [4]byte ;_f .LittleEndian .PutUint32 (_bgb [:],uint32 (_db .P ));_dbf .Write (_bgb [:]);_fbd .Log .Trace ("\u0067o\u0020\u0050\u003a\u0020\u0025\u0020x",_bgb );_dbf .Write ([]byte (_ge .ID0 ));_fbd .Log .Trace ("\u0074\u0068\u0069\u0073\u002e\u0052\u0020\u003d\u0020\u0025d\u0020\u0065\u006e\u0063\u0072\u0079\u0070t\u004d\u0065\u0074\u0061\u0064\u0061\u0074\u0061\u0020\u0025\u0076",_db .R ,_db .EncryptMetadata );if (_db .R >=4)&&!_db .EncryptMetadata {_dbf .Write ([]byte {0xff,0xff,0xff,0xff});};_cf :=_dbf .Sum (nil );if _db .R >=3{_dbf =_fd .New ();for _aab :=0;_aab < 50;_aab ++{_dbf .Reset ();_dbf .Write (_cf [0:_ge .Length /8]);_cf =_dbf .Sum (nil );};};if _db .R >=3{return _cf [0:_ge .Length /8];};return _cf [0:5];};func (_gfe stdHandlerR6 )alg10 (_eac *StdEncryptDict ,_acdb []byte )error {if _egf :=_dd ("\u0061\u006c\u00671\u0030","\u004b\u0065\u0079",32,_acdb );_egf !=nil {return _egf ;};_caea :=uint64 (uint32 (_eac .P ))|(_fb .MaxUint32 <<32);Perms :=make ([]byte ,16);_f .LittleEndian .PutUint64 (Perms [:8],_caea );if _eac .EncryptMetadata {Perms [8]='T';}else {Perms [8]='F';};copy (Perms [9:12],"\u0061\u0064\u0062");if _ ,_ddcf :=_a .ReadFull (_gd .Reader ,Perms [12:16]);_ddcf !=nil {return _ddcf ;};_ddb ,_cbdb :=_gad (_acdb [:32]);if _cbdb !=nil {return _cbdb ;};_feb :=_df (_ddb );_feb .CryptBlocks (Perms ,Perms );_eac .Perms =Perms [:16];return nil ;};func (_cfa stdHandlerR6 )alg2a (_bbd *StdEncryptDict ,_dacf []byte )([]byte ,Permissions ,error ){if _cbd :=_dd ("\u0061\u006c\u00672\u0061","\u004f",48,_bbd .O );_cbd !=nil {return nil ,0,_cbd ;};if _gcg :=_dd ("\u0061\u006c\u0
|
|
|
|
|
|
|
|
// Authenticate implements StdHandler interface.
|
|
|
|
func (_gaa stdHandlerR4 )Authenticate (d *StdEncryptDict ,pass []byte )([]byte ,Permissions ,error ){_fbd .Log .Trace ("\u0044\u0065b\u0075\u0067\u0067\u0069n\u0067\u0020a\u0075\u0074\u0068\u0065\u006e\u0074\u0069\u0063a\u0074\u0069\u006f\u006e\u0020\u002d\u0020\u006f\u0077\u006e\u0065\u0072 \u0070\u0061\u0073\u0073");_bafg ,_gccd :=_gaa .alg7 (d ,pass );if _gccd !=nil {return nil ,0,_gccd ;};if _bafg !=nil {_fbd .Log .Trace ("\u0074h\u0069\u0073\u002e\u0061u\u0074\u0068\u0065\u006e\u0074i\u0063a\u0074e\u0064\u0020\u003d\u0020\u0054\u0072\u0075e");return _bafg ,PermOwner ,nil ;};_fbd .Log .Trace ("\u0044\u0065bu\u0067\u0067\u0069n\u0067\u0020\u0061\u0075the\u006eti\u0063\u0061\u0074\u0069\u006f\u006e\u0020- \u0075\u0073\u0065\u0072\u0020\u0070\u0061s\u0073");_bafg ,_gccd =_gaa .alg6 (d ,pass );if _gccd !=nil {return nil ,0,_gccd ;};if _bafg !=nil {_fbd .Log .Trace ("\u0074h\u0069\u0073\u002e\u0061u\u0074\u0068\u0065\u006e\u0074i\u0063a\u0074e\u0064\u0020\u003d\u0020\u0054\u0072\u0075e");return _bafg ,d .P ,nil ;};return nil ,0,nil ;};var _ StdHandler =stdHandlerR4 {};func (_dff stdHandlerR4 )alg7 (_gcb *StdEncryptDict ,_bbgg []byte )([]byte ,error ){_bbgb :=_dff .alg3Key (_gcb .R ,_bbgg );_bcg :=make ([]byte ,len (_gcb .O ));if _gcb .R ==2{_aaa ,_ec :=_bf .NewCipher (_bbgb );if _ec !=nil {return nil ,_gc .New ("\u0066\u0061\u0069\u006c\u0065\u0064\u0020\u0063\u0069\u0070\u0068\u0065\u0072");};_aaa .XORKeyStream (_bcg ,_gcb .O );}else if _gcb .R >=3{_gbg :=append ([]byte {},_gcb .O ...);for _cdb :=0;_cdb < 20;_cdb ++{_af :=append ([]byte {},_bbgb ...);for _bd :=0;_bd < len (_bbgb );_bd ++{_af [_bd ]^=byte (19-_cdb );};_fac ,_gdd :=_bf .NewCipher (_af );if _gdd !=nil {return nil ,_gc .New ("\u0066\u0061\u0069\u006c\u0065\u0064\u0020\u0063\u0069\u0070\u0068\u0065\u0072");};_fac .XORKeyStream (_bcg ,_gbg );_gbg =append ([]byte {},_bcg ...);};}else {return nil ,_gc .New ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020R");};_feg ,_fbf :=_dff .alg6 (_gcb ,_bcg );if _fbf !=nil {return nil ,nil ;};return _feg ,nil ;};func (stdHandlerR4 )paddedPass (_bab []byte )[]byte {_ag :=make ([]byte ,32);_fbdd :=copy (_ag ,_bab );for ;_fbdd < 32;_fbdd ++{_ag [_fbdd ]=_fa [_fbdd -len (_bab )];};return _ag ;};func _gad (_cdg []byte )(_c .Block ,error ){_eg ,_caf :=_ab .NewCipher (_cdg );if _caf !=nil {_fbd .Log .Error ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0063\u006f\u0075\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0063\u0072\u0065\u0061\u0074\u0065\u0020A\u0045\u0053\u0020\u0063\u0069p\u0068\u0065r\u003a\u0020\u0025\u0076",_caf );return nil ,_caf ;};return _eg ,nil ;};
|
2020-10-19 10:58:10 +00:00
|
|
|
|
|
|
|
// Allowed checks if a set of permissions can be granted.
|
2020-11-11 18:48:37 +00:00
|
|
|
func (_edb Permissions )Allowed (p2 Permissions )bool {return _edb &p2 ==p2 };type ecbEncrypter ecb ;type ecbDecrypter ecb ;func (_gccb *ecbEncrypter )BlockSize ()int {return _gccb ._acg };const (PermOwner =Permissions (_fb .MaxUint32 );PermPrinting =Permissions (1<<2);PermModify =Permissions (1<<3);PermExtractGraphics =Permissions (1<<4);PermAnnotate =Permissions (1<<5);PermFillForms =Permissions (1<<8);PermDisabilityExtract =Permissions (1<<9);PermRotateInsert =Permissions (1<<10);PermFullPrintQuality =Permissions (1<<11););
|
|
|
|
|
|
|
|
// GenerateParams generates and sets O and U parameters for the encryption dictionary.
|
|
|
|
// It expects R, P and EncryptMetadata fields to be set.
|
|
|
|
func (_bbga stdHandlerR4 )GenerateParams (d *StdEncryptDict ,opass ,upass []byte )([]byte ,error ){O ,_eca :=_bbga .alg3 (d .R ,upass ,opass );if _eca !=nil {_fbd .Log .Debug ("\u0045R\u0052\u004fR\u003a\u0020\u0045r\u0072\u006f\u0072\u0020\u0067\u0065\u006ee\u0072\u0061\u0074\u0069\u006e\u0067 \u004f\u0020\u0066\u006f\u0072\u0020\u0065\u006e\u0063\u0072\u0079p\u0074\u0069\u006f\u006e\u0020\u0028\u0025\u0073\u0029",_eca );return nil ,_eca ;};d .O =O ;_fbd .Log .Trace ("\u0067\u0065\u006e\u0020\u004f\u003a\u0020\u0025\u0020\u0078",O );_cae :=_bbga .alg2 (d ,upass );U ,_eca :=_bbga .alg5 (_cae ,upass );if _eca !=nil {_fbd .Log .Debug ("\u0045R\u0052\u004fR\u003a\u0020\u0045r\u0072\u006f\u0072\u0020\u0067\u0065\u006ee\u0072\u0061\u0074\u0069\u006e\u0067 \u004f\u0020\u0066\u006f\u0072\u0020\u0065\u006e\u0063\u0072\u0079p\u0074\u0069\u006f\u006e\u0020\u0028\u0025\u0073\u0029",_eca );return nil ,_eca ;};d .U =U ;_fbd .Log .Trace ("\u0067\u0065\u006e\u0020\u0055\u003a\u0020\u0025\u0020\u0078",U );return _cae ,nil ;};func (_bgg stdHandlerR4 )alg4 (_aedc []byte ,_ce []byte )([]byte ,error ){_dde ,_ffc :=_bf .NewCipher (_aedc );if _ffc !=nil {return nil ,_gc .New ("\u0066a\u0069l\u0065\u0064\u0020\u0072\u0063\u0034\u0020\u0063\u0069\u0070\u0068");};_cg :=[]byte (_fa );_ebga :=make ([]byte ,len (_cg ));_dde .XORKeyStream (_ebga ,_cg );return _ebga ,nil ;};func (_bb *ecbEncrypter )CryptBlocks (dst ,src []byte ){if len (src )%_bb ._acg !=0{_fbd .Log .Error ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0045\u0043\u0042\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u003a \u0069\u006e\u0070\u0075\u0074\u0020\u006e\u006f\u0074\u0020\u0066\u0075\u006c\u006c\u0020\u0062\u006c\u006f\u0063\u006b\u0073");return ;};if len (dst )< len (src ){_fbd .Log .Error ("\u0045R\u0052\u004fR\u003a\u0020\u0045C\u0042\u0020\u0065\u006e\u0063\u0072\u0079p\u0074\u003a\u0020\u006f\u0075\u0074p\u0075\u0074\u0020\u0073\u006d\u0061\u006c\u006c\u0065\u0072\u0020t\u0068\u0061\u006e\u0020\u0069\u006e\u0070\u0075\u0074");return ;};for len (src )> 0{_bb ._baa .Encrypt (dst ,src [:_bb ._acg ]);src =src [_bb ._acg :];dst =dst [_bb ._acg :];};};type errInvalidField struct{Func string ;Field string ;Exp int ;Got int ;};func _ddd (_dda []byte ,_ffd int ){_bdd :=_ffd ;for _bdd < len (_dda ){copy (_dda [_bdd :],_dda [:_bdd ]);_bdd *=2;};};func (_adf *ecbDecrypter )CryptBlocks (dst ,src []byte ){if len (src )%_adf ._acg !=0{_fbd .Log .Error ("\u0045\u0052\u0052\u004f\u0052:\u0020\u0045\u0043\u0042\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u003a \u0069\u006e\u0070\u0075\u0074\u0020\u006e\u006f\u0074\u0020\u0066\u0075\u006c\u006c\u0020\u0062\u006c\u006f\u0063\u006b\u0073");return ;};if len (dst )< len (src ){_fbd .Log .Error ("\u0045R\u0052\u004fR\u003a\u0020\u0045C\u0042\u0020\u0064\u0065\u0063\u0072\u0079p\u0074\u003a\u0020\u006f\u0075\u0074p\u0075\u0074\u0020\u0073\u006d\u0061\u006c\u006c\u0065\u0072\u0020t\u0068\u0061\u006e\u0020\u0069\u006e\u0070\u0075\u0074");return ;};for len (src )> 0{_adf ._baa .Decrypt (dst ,src [:_adf ._acg ]);src =src [_adf ._acg :];dst =dst [_adf ._acg :];};};func (_beb stdHandlerR6 )alg11 (_gdb *StdEncryptDict ,_febb []byte )([]byte ,error ){if _fccf :=_dd ("\u0061\u006c\u00671\u0031","\u0055",48,_gdb .U );_fccf !=nil {return nil ,_fccf ;};_bgc :=make ([]byte ,len (_febb )+8);_fbaf :=copy (_bgc ,_febb );_fbaf +=copy (_bgc [_fbaf :],_gdb .U [32:40]);_ecb ,_cdc :=_beb .alg2b (_gdb .R ,_bgc ,_febb ,nil );if _cdc !=nil {return nil ,_cdc ;};_ecb =_ecb [:32];if !_gcc .Equal (_ecb ,_gdb .U [:32]){return nil ,nil ;};return _ecb ,nil ;};const (EventDocOpen =AuthEvent ("\u0044o\u0063\u004f\u0070\u0065\u006e");EventEFOpen =AuthEvent ("\u0045\u0046\u004f\u0070\u0065\u006e"););func _be (_ebd []byte )([]byte ,error ){_ef :=_b .New ();_ef .Write (_ebd );return _ef .Sum (nil ),nil };
|
|
|
|
|
|
|
|
// AuthEvent is an event type that triggers authentication.
|
|
|
|
type AuthEvent string ;var _ StdHandler =stdHandlerR6 {};func _e (_adb _c .Block )_c .BlockMode {return (*ecbDecrypter )(_aa (_adb ))};
|
|
|
|
|
|
|
|
// Authenticate implements StdHandler interface.
|
|
|
|
func (_gdc stdHandlerR6 )Authenticate (d *StdEncryptDict ,pass []byte )([]byte ,Permissions ,error ){return _gdc .alg2a (d ,pass );};
|