(response []byte, sig *auth.SigInfo)
| 181 | } |
| 182 | |
| 183 | func parseNewDeviceLoginResponse(response []byte, sig *auth.SigInfo) (loginstate.State, error) { |
| 184 | if len(sig.ExchangeKey) == 0 { |
| 185 | return -999, errors.New("empty exchange key") |
| 186 | } |
| 187 | |
| 188 | var encrypted login.SsoNTLoginEncryptedData |
| 189 | err := proto.Unmarshal(response, &encrypted) |
| 190 | if err != nil { |
| 191 | return -999, err |
| 192 | } |
| 193 | |
| 194 | if encrypted.GcmCalc != nil { |
| 195 | decrypted, err := crypto.AESGCMDecrypt(encrypted.GcmCalc, sig.ExchangeKey) |
| 196 | if err != nil { |
| 197 | return -999, err |
| 198 | } |
| 199 | var base login.SsoNTLoginBase |
| 200 | err = proto.Unmarshal(decrypted, &base) |
| 201 | if err != nil { |
| 202 | return -999, err |
| 203 | } |
| 204 | var body login.SsoNTLoginResponse |
| 205 | err = proto.Unmarshal(base.Body, &body) |
| 206 | if err != nil { |
| 207 | return -999, err |
| 208 | } |
| 209 | ret := loginstate.State(base.Header.Error.ErrorCode) |
| 210 | if body.Credentials == nil { |
| 211 | return ret, errors.New(ret.Name()) |
| 212 | } |
| 213 | sig.Tgt = body.Credentials.Tgt |
| 214 | sig.D2 = body.Credentials.D2 |
| 215 | sig.D2Key = body.Credentials.D2Key |
| 216 | sig.TempPwd = body.Credentials.TempPassword |
| 217 | return ret, nil |
| 218 | } |
| 219 | return -999, errors.New("empty data") |
| 220 | } |
| 221 | |
| 222 | func all(b []string) bool { |
| 223 | for _, b1 := range b { |
no test coverage detected