gnunet-svn
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]