[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-challenger] 21/24: small fix
From: |
gnunet |
Subject: |
[taler-challenger] 21/24: small fix |
Date: |
Mon, 16 Sep 2024 13:26:10 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository challenger.
commit 0d9cfe4eb122ac3829d9d9168482f24fce9342ca
Author: Bohdan Potuzhnyi <potub1@bfh.ch>
AuthorDate: Sun Sep 15 21:43:37 2024 +0000
small fix
---
src/challenger/.gitignore | 1 +
src/challenger/src/challenger_cm_enums.c | 58 ++++++++++++++++++++++++++++++++
src/challenger/src/challenger_cm_enums.h | 58 ++++++++++++++++++++++++++++++++
3 files changed, 117 insertions(+)
diff --git a/src/challenger/.gitignore b/src/challenger/.gitignore
index f4b8f4b..e7d26e6 100644
--- a/src/challenger/.gitignore
+++ b/src/challenger/.gitignore
@@ -1 +1,2 @@
challenger-admin
+src/.*
\ No newline at end of file
diff --git a/src/challenger/src/challenger_cm_enums.c
b/src/challenger/src/challenger_cm_enums.c
new file mode 100644
index 0000000..1fc4c50
--- /dev/null
+++ b/src/challenger/src/challenger_cm_enums.c
@@ -0,0 +1,58 @@
+/*
+ This file is part of Challenger
+ Copyright (C) 2023 Taler Systems SA
+
+ Challenger is free software; you can redistribute it and/or modify it under
the
+ terms of the GNU Affero General Public License as published by the Free
Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Challenger is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
details.
+
+ You should have received a copy of the GNU Affero General Public License
along with
+ Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file challenger_cm_enums.c
+ * @brief enums to handle challenge method
+ * @author Bohdan Potuzhnyi
+ * @author Vlada Svirsh
+ */
+
+#include "challenger_cm_enums.h"
+#include <string.h>
+#include <stdint.h>
+
+
+enum CHALLENGER_CM
+CHALLENGER_cm_from_string(const char *method_str)
+{
+ if (NULL == method_str || 0 == strcmp(method_str, ""))
+ return CHALLENGER_CM_EMPTY;
+
+ if (0 == strcmp(method_str, "plain"))
+ return CHALLENGER_CM_PLAIN;
+
+ if (0 == strcmp(method_str, "S256") || 0 == strcmp(method_str, "sha256"))
+ return CHALLENGER_CM_S256;
+
+ return CHALLENGER_CM_UNKNOWN;
+}
+
+
+enum CHALLENGER_CM
+CHALLENGER_cm_from_int(uint32_t method_int)
+{
+ switch (method_int)
+ {
+ case 0:
+ return CHALLENGER_CM_EMPTY;
+ case 1:
+ return CHALLENGER_CM_PLAIN;
+ case 2:
+ return CHALLENGER_CM_S256;
+ default:
+ return CHALLENGER_CM_UNKNOWN; // Invalid or unrecognized value
+ }
+}
\ No newline at end of file
diff --git a/src/challenger/src/challenger_cm_enums.h
b/src/challenger/src/challenger_cm_enums.h
new file mode 100644
index 0000000..57b87cd
--- /dev/null
+++ b/src/challenger/src/challenger_cm_enums.h
@@ -0,0 +1,58 @@
+/*
+ This file is part of Challenger
+ Copyright (C) 2023 Taler Systems SA
+
+ Challenger is free software; you can redistribute it and/or modify it under
the
+ terms of the GNU Affero General Public License as published by the Free
Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Challenger is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
details.
+
+ You should have received a copy of the GNU Affero General Public License
along with
+ Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file challenger_cm_enums.h
+ * @brief enums to handle challenge method
+ * @author Bohdan Potuzhnyi
+ * @author Vlada Svirsh
+ */
+
+#ifndef CHALLENGER_CM_ENUMS_H
+#define CHALLENGER_CM_ENUMS_H
+
+#include <stdint.h>
+
+enum CHALLENGER_CM
+{
+ CHALLENGER_CM_EMPTY,
+ CHALLENGER_CM_PLAIN,
+ CHALLENGER_CM_S256,
+ CHALLENGER_CM_UNKNOWN
+};
+
+
+/**
+ * Convert a string to the corresponding enum value.
+ *
+ * @param method_str the string representing the code challenge method
+ * @return the corresponding enum value, or CHALLENGER_CM_UNKNOWN if not
recognized
+ */
+enum CHALLENGER_CM
+CHALLENGER_cm_from_string(const char *method_str);
+
+
+/**
+ * Convert an int to the corresponding enum value.
+ * Returns CHALLENGER_CM_UNKNOWN if the int does not match a valid enum value.
+ *
+ * @param method_int integer representation of the code challenge method
+ * @return the corresponding enum value
+ */
+enum CHALLENGER_CM
+CHALLENGER_cm_from_int(uint32_t method_int);
+
+
+#endif /* CHALLENGER_CM_ENUMS_H */
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-challenger] 05/24: small update of logs for authorize.c, (continued)
- [taler-challenger] 05/24: small update of logs for authorize.c, gnunet, 2024/09/16
- [taler-challenger] 04/24: small changes to logs and db function names, gnunet, 2024/09/16
- [taler-challenger] 02/24: in theory done, but needs live testing and adjustments, gnunet, 2024/09/16
- [taler-challenger] 03/24: base64 less strange now, still needs check for a normal way, gnunet, 2024/09/16
- [taler-challenger] 09/24: happy path pkce tests added, gnunet, 2024/09/16
- [taler-challenger] 01/24: db part is done(new approach), gnunet, 2024/09/16
- [taler-challenger] 08/24: tests for pkce added, gnunet, 2024/09/16
- [taler-challenger] 07/24: small db validation_get.c update, gnunet, 2024/09/16
- [taler-challenger] 18/24: code cleaning and styling, gnunet, 2024/09/16
- [taler-challenger] 10/24: added test for the wrong code_verifier, gnunet, 2024/09/16
- [taler-challenger] 21/24: small fix,
gnunet <=
- [taler-challenger] 22/24: small cleanup, gnunet, 2024/09/16
- [taler-challenger] 06/24: small db start_pkce.c update, gnunet, 2024/09/16
- [taler-challenger] 12/24: merged 2 pkce test files into one, gnunet, 2024/09/16
- [taler-challenger] 14/24: version update, gnunet, 2024/09/16
- [taler-challenger] 16/24: change to using GNUNET_STRINGS_base64url_encode, gnunet, 2024/09/16
- [taler-challenger] 23/24: move from src to main dir, uncrustify, gnunet, 2024/09/16
- [taler-challenger] 13/24: file cleaning, gnunet, 2024/09/16
- [taler-challenger] 11/24: adding test .sh file, gnunet, 2024/09/16
- [taler-challenger] 15/24: small update of makefile, gnunet, 2024/09/16
- [taler-challenger] 24/24: various minor fixes, most importantly correct DB migration, gnunet, 2024/09/16