Documentation ¶
Index ¶
- Variables
- func CalcMd5File(filename string) (string, error)
- func GenerateAccessHash(user User, visitorID int) int64
- func GenerateBaseHash(userID int, timestamp int64, salt int) int64
- func GenerateNonce(size int) []byte
- func GenerateStringNonce(size int) string
- func NewAesCBCDecrypt(aesKey, aesIV []byte) (cipher.BlockMode, error)
- func NewAesCBCEncrypt(aesKey, aesIV []byte) (cipher.BlockMode, error)
- func RandomBytes(size int) []byte
- func RandomString(size int) string
- func Sha1Digest(data []byte) []byte
- func Sha256Digest(data []byte) []byte
- func VerifyAccessHash(userID int, visitorID int, providedAccessHash int64) bool
- type AES256IGECryptor
- type AesCTR128Encrypt
- type AesCTR128KeySizeError
- type AuthKey
- func (k *AuthKey) AesIgeDecrypt(msgKey, rawData []byte) ([]byte, error)
- func (k *AuthKey) AesIgeDecryptV1(msgKey, rawData []byte) ([]byte, error)
- func (k *AuthKey) AesIgeEncrypt(rawData []byte) ([]byte, []byte, error)
- func (k *AuthKey) AesIgeEncryptV1(rawData []byte) ([]byte, []byte, error)
- func (k *AuthKey) AuthKey() []byte
- func (k *AuthKey) AuthKeyId() int64
- func (k *AuthKey) Equals(o *AuthKey) bool
- type PasswordKdfAlgoModPow
- type RSACryptor
- type SRPUtil
- func (m *SRPUtil) CalcClientM(newSalt1, xBytes, srpB []byte) ([]byte, []byte)
- func (m *SRPUtil) CalcClientM2(newSalt1, aBytes, ABytes, xBytes, srpB []byte) []byte
- func (m *SRPUtil) CalcM(newSalt1, vBytes, srpA, srpb, srpB []byte) []byte
- func (m *SRPUtil) CalcSRPB(vBytes []byte) ([]byte, []byte)
- func (m *SRPUtil) CalcSRPB2(bNonce, vBytes []byte) []byte
- func (m *SRPUtil) CheckNewSalt1(newSalt1 []byte) bool
- func (m *SRPUtil) GetV(newSalt1, passwordBytes []byte) *big.Int
- func (m *SRPUtil) GetVBytes(newSalt1, passwordBytes []byte) []byte
- func (m *SRPUtil) GetX(newSalt1, passwordBytes []byte) []byte
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var Database = make(map[int]User)
Database simulates a simple in-memory user database
Functions ¶
func CalcMd5File ¶
TODO(@benqi): remove to baselib
func GenerateAccessHash ¶
GenerateAccessHash generates a unique access hash for a user accessed by a specific visitor and returns it as int64
func GenerateBaseHash ¶
GenerateBaseHash generates a base hash for a user and returns it as int64
func GenerateNonce ¶
func GenerateStringNonce ¶
func RandomBytes ¶
func RandomString ¶
func Sha1Digest ¶
func Sha256Digest ¶
Types ¶
type AES256IGECryptor ¶
type AES256IGECryptor struct {
// contains filtered or unexported fields
}
func NewAES256IGECryptor ¶
func NewAES256IGECryptor(aesKey, aesIV []byte) *AES256IGECryptor
type AesCTR128Encrypt ¶
type AesCTR128Encrypt struct {
// contains filtered or unexported fields
}
func NewAesCTR128Encrypt ¶
func NewAesCTR128Encrypt(key []byte, iv []byte) (*AesCTR128Encrypt, error)
key长度必须为16、24或32
func (*AesCTR128Encrypt) Encrypt ¶
func (e *AesCTR128Encrypt) Encrypt(plaintext []byte) []byte
type AesCTR128KeySizeError ¶
type AesCTR128KeySizeError int
func (AesCTR128KeySizeError) Error ¶
func (k AesCTR128KeySizeError) Error() string
type AuthKey ¶
type AuthKey struct {
// contains filtered or unexported fields
}
func CreateAuthKey ¶
func CreateAuthKey() *AuthKey
CreateAuthKey
## android client, pushAuthKey algo:
- authKey if (SharedConfig.pushAuthKey == null) { SharedConfig.pushAuthKey = new byte[256]; Utilities.random.nextBytes(SharedConfig.pushAuthKey); SharedConfig.saveConfig(); }
- calcAuthKeyId SharedConfig.pushAuthKeyId = new byte[8]; byte[] authKeyHash = Utilities.computeSHA1(SharedConfig.pushAuthKey); System.arraycopy(authKeyHash, authKeyHash.length - 8, SharedConfig.pushAuthKeyId, 0, 8);
for bots...
func NewAuthKey ¶
func NewClientAuthKey ¶
func (*AuthKey) AesIgeDecrypt ¶
func (*AuthKey) AesIgeDecryptV1 ¶
func (*AuthKey) AesIgeEncrypt ¶
func (*AuthKey) AesIgeEncryptV1 ¶
AesIgeEncryptV1
| salt <br> int64 | `session_id` <br> int64 | `message_id` <br> int64 | `seq_no` <br> int32 |`message_data_length` <br> int32 | `message_data` <br> bytes | padding12..1024 <br> bytes| |:-:|:-:|:-:|:-:|:-:|:-:|:-:|
type PasswordKdfAlgoModPow ¶
type RSACryptor ¶
type RSACryptor struct {
// contains filtered or unexported fields
}
func NewRSACryptor ¶
func NewRSACryptor(keyFile string) (*RSACryptor, error)
func NewRSACryptorByKeyData ¶
func NewRSACryptorByKeyData(pkcs1PemPrivateKey []byte) (*RSACryptor, error)
func (*RSACryptor) Decrypt ¶
func (m *RSACryptor) Decrypt(b []byte) []byte
func (*RSACryptor) Encrypt ¶
func (m *RSACryptor) Encrypt(b []byte) []byte
type SRPUtil ¶
type SRPUtil struct { *PasswordKdfAlgoModPow // contains filtered or unexported fields }
func MakeSRPUtil ¶
func MakeSRPUtil(algo *PasswordKdfAlgoModPow) *SRPUtil
func (*SRPUtil) CalcClientM ¶
func (*SRPUtil) CalcClientM2 ¶
func (*SRPUtil) CheckNewSalt1 ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.