1/*
2 This file is part of Mtproto-proxy Library.
3
4 Mtproto-proxy Library is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 Mtproto-proxy Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with Mtproto-proxy Library. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright 2014-2016 Telegram Messenger Inc
18 2014-2016 Nikolai Durov
19*/
20
21#define _FILE_OFFSET_BITS 64
22
23#include <assert.h>
24#include <fcntl.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <stdarg.h>
28#include <stddef.h>
29#include <string.h>
30#include <time.h>
31#include <unistd.h>
32
33// #include <openssl/aes.h>
34
35#include "kprintf.h"
36#include "precise-time.h"
37#include "net/net-events.h" // for show_ipv6()
38
39#include "net/net-config.h"
40
41char pwd_config_buf[MAX_PWD_CONFIG_LEN + 128];
42int pwd_config_len;
43char pwd_config_md5[33] = {'n', 'o', 'n', 'e', 0};
44
45
46int select_best_key_signature (int key_signature, int extra_num, const int *extra_key_signatures) {
47 assert (extra_num >= 0 && extra_num <= 16);
48 if (main_secret.secret_len < 4) {
49 return 0;
50 }
51 int main_key_id = main_secret.key_signature;
52 if (main_key_id == key_signature) {
53 return main_key_id;
54 }
55 int i;
56 for (i = 0; i < extra_num; i++) {
57 if (main_key_id == extra_key_signatures[i]) {
58 return main_key_id;
59 }
60 }
61 return 0;
62}
63
64