bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose SSSD - auth utils helpers
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose Copyright (C) Sumit Bose <sbose@redhat.com> 2015
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose This program is free software; you can redistribute it and/or modify
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose it under the terms of the GNU General Public License as published by
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose the Free Software Foundation; either version 3 of the License, or
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose (at your option) any later version.
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose This program is distributed in the hope that it will be useful,
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose GNU General Public License for more details.
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose You should have received a copy of the GNU General Public License
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose/* This file is use by SSSD clients and the main daemons. Please do not add
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose * code which is specific to only one of them. */
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Boseerrno_t sss_auth_pack_2fa_blob(const char *fa1, size_t fa1_len,
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose if (fa1 == NULL || *fa1 == '\0' || fa1_len > UINT32_MAX
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose || fa2 == NULL || *fa2 == '\0' || fa2_len > UINT32_MAX
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose *_2fa_blob_len = fa1_len + fa2_len + 2 + 2 * sizeof(uint32_t);
bc052ea17d858c19f9cb9c9e2bc602e754f68831Sumit Bose SAFEALIGN_COPY_UINT32(buf + c, &tmp_uint32_t, &c);
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Boseerrno_t sss_auth_pack_sc_blob(const char *pin, size_t pin_len,
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Bose if (pin_len > UINT32_MAX || token_name_len > UINT32_MAX
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Bose /* A missing pin is ok in the case of a reader with a keyboard */
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Bose /* len should not include the trailing \0 */
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Bose if (token_name_len == 0 || token_name[token_name_len - 1] == '\0') {
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Bose if (module_name_len == 0 || module_name[module_name_len - 1] == '\0') {
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Bose if (key_id_len == 0 || key_id[key_id_len - 1] == '\0') {
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Bose *_sc_blob_len = pin_len + token_name_len + module_name_len + key_id_len + 4
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Bose SAFEALIGN_COPY_UINT32(buf + c, &tmp_uint32_t, &c);
dd17a3aaddab6f122dff3bd15b7005464c07c0eaSumit Bose SAFEALIGN_COPY_UINT32(buf + c, &tmp_uint32_t, &c);