xiaoxiang781216 commented on code in PR #3557:
URL: https://github.com/apache/nuttx-apps/pull/3557#discussion_r3503220232
##########
fsutils/passwd/Kconfig:
##########
@@ -6,8 +6,15 @@
config FSUTILS_PASSWD
bool "Password file support"
default n
+ select CRYPTO
+ select ALLOW_BSD_COMPONENTS
+ select CRYPTO_CRYPTODEV
Review Comment:
let's use depends on or skip PBKDF2-HMAC-SHA256 if crypto isn't enabled
##########
fsutils/passwd/Kconfig:
##########
@@ -23,20 +30,14 @@ config FSUTILS_PASSWD_IOBUFFER_SIZE
int "Allocated I/O buffer size"
default 512
-config FSUTILS_PASSWD_KEY1
- hex "Encryption key value 1"
- default 0x12345678
-
-config FSUTILS_PASSWD_KEY2
- hex "Encryption key value 2"
- default 0x9abcdef0
-
-config FSUTILS_PASSWD_KEY3
- hex "Encryption key value 3"
- default 0x12345678
-
-config FSUTILS_PASSWD_KEY4
- hex "Encryption key value 4"
- default 0x9abcdef0
+ config FSUTILS_PASSWD_PBKDF2_ITERATIONS
Review Comment:
remove indent
##########
testing/pbkdf2/pbkdf2_test.c:
##########
@@ -0,0 +1,287 @@
+/****************************************************************************
+ * apps/testing/pbkdf2/pbkdf2_test.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <fsutils/passwd.h>
+
+#include "passwd.h"
+#include "passwd_pbkdf2.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define TEST_USERNAME "testuser"
+#define TEST_PASSWORD "MySecret1!"
+#define WRONG_PASSWORD "WrongPass"
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct pbkdf2_vector_s
+{
+ FAR const char *password;
+ size_t passwordlen;
+ FAR const char *salt;
+ size_t saltlen;
+ uint32_t iterations;
+ size_t dklen;
+ FAR const uint8_t *expected;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* PBKDF2-HMAC-SHA256 test vectors from RFC 6070 (appendix B). */
+
+static const uint8_t g_vector1[] =
+{
+ 0x12, 0x0f, 0xb6, 0xcf, 0xfc, 0xf8, 0xb3, 0x2c,
+ 0x43, 0xe7, 0x22, 0x52, 0x56, 0xc4, 0xf8, 0x37,
+ 0xa8, 0x65, 0x48, 0xc9
+};
+
+static const uint8_t g_vector2[] =
+{
+ 0xae, 0x4d, 0x0c, 0x95, 0xaf, 0x6b, 0x46, 0xd3,
+ 0x2d, 0x0a, 0xdf, 0xf9, 0x28, 0xf0, 0x6d, 0xd0,
+ 0x2a, 0x30, 0x3f, 0x8e
+};
+
+static const uint8_t g_vector3[] =
+{
+ 0xc5, 0xe4, 0x78, 0xd5, 0x92, 0x88, 0xc8, 0x41,
+ 0xaa, 0x53, 0x0d, 0xb6, 0x84, 0x5c, 0x4c, 0x8d,
+ 0x96, 0x28, 0x93, 0xa0
+};
+
+static const uint8_t g_vector4[] =
+{
+ 0xcf, 0x81, 0xc6, 0x6f, 0xe8, 0xcf, 0xc0, 0x4d,
+ 0x1f, 0x31, 0xec, 0xb6, 0x5d, 0xab, 0x40, 0x89,
+ 0xf7, 0xf1, 0x79, 0xe8
+};
+
+static const uint8_t g_vector5[] =
+{
+ 0x34, 0x8c, 0x89, 0xdb, 0xcb, 0xd3, 0x2b, 0x2f,
+ 0x32, 0xd8, 0x14, 0xb8, 0x11, 0x6e, 0x84, 0xcf,
+ 0x2b, 0x17, 0x34, 0x7e, 0xbc, 0x18, 0x00, 0x18,
+ 0x1c
+};
+
+static const uint8_t g_vector6[] =
+{
+ 0x89, 0xb6, 0x9d, 0x05, 0x16, 0xf8, 0x29, 0x89,
+ 0x3c, 0x69, 0x62, 0x26, 0x65, 0x0a, 0x86, 0x87
+};
+
+static const struct pbkdf2_vector_s g_vectors[] =
Review Comment:
should we move pdkdf2 to testing/drivers/crypto/pbkdf2.c
##########
fsutils/passwd/passwd_base64.c:
##########
@@ -26,137 +26,162 @@
#include <nuttx/config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <fcntl.h>
-#include <unistd.h>
#include <errno.h>
+#include <stdint.h>
-#include <nuttx/crypto/rng90.h>
+#include "passwd_base64.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#ifndef CONFIG_EXAMPLES_RNG90_DEVPATH
-# define CONFIG_EXAMPLES_RNG90_DEVPATH "/dev/rng0"
-#endif
+/* RFC 4648 section 5 base64url alphabet (no padding). */
-#define RNG90_MAX_BYTES 32
+static const char g_base64url[] =
Review Comment:
should we call netutils/codecs/base64.c?
##########
testing/pbkdf2/pbkdf2_test.c:
##########
@@ -0,0 +1,287 @@
+/****************************************************************************
+ * apps/testing/pbkdf2/pbkdf2_test.c
Review Comment:
move to testing/crypto/passwd
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]