gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: Fix DE SVN checksum@


From: gnunet
Subject: [taler-anastasis] branch master updated: Fix DE SVN checksum@
Date: Sat, 27 Mar 2021 03:02:53 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 027070e  Fix DE SVN checksum@
027070e is described below

commit 027070e0345de91fa524edcdaf6bcffea6580cc8
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Mar 27 03:02:49 2021 +0100

    Fix DE SVN checksum@
---
 src/reducer/validation_DE_SVN.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/reducer/validation_DE_SVN.c b/src/reducer/validation_DE_SVN.c
index aad3acd..bfc406d 100644
--- a/src/reducer/validation_DE_SVN.c
+++ b/src/reducer/validation_DE_SVN.c
@@ -23,6 +23,23 @@
 #include <string.h>
 #include <stdbool.h>
 
+/**
+ * Sum up all digits in @a v and return the result.
+ */
+static unsigned int
+q (unsigned int v)
+{
+  unsigned int r = 0;
+
+  while (0 != v)
+  {
+    r += v % 10;
+    v = v / 10;
+  }
+  return r;
+}
+
+
 /**
  * Function to validate a German Social Security number.
  *
@@ -49,14 +66,16 @@ DE_SVN_check (const char *ssn_number)
 
     if ( ('0' > c) || ('9' < c) )
       return false;
-    sum += (c - '0') * factors[i];
+    sum += q ((c - '0') * factors[i]);
   }
   {
     unsigned char c = (unsigned char) ssn_number[8];
+    unsigned int v = (c - 'A' + 1);
 
     if ( ('A' > c) || ('Z' < c) )
       return false;
-    sum += (c - 'A' + 1) * factors[8];
+    sum += q ((v / 10) * factors[8]);
+    sum += q ((v % 10) * factors[9]);
   }
   for (unsigned int i = 9; i<11; i++)
   {
@@ -64,7 +83,7 @@ DE_SVN_check (const char *ssn_number)
 
     if ( ('0' > c) || ('9' < c) )
       return false;
-    sum += (c - '0') * factors[i];
+    sum += q ((c - '0') * factors[i + 1]);
   }
   if (ssn_number[11] != '0' + (sum % 10))
     return false;

-- 
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]