xiaoxiang781216 commented on code in PR #3640:
URL: https://github.com/apache/nuttx-apps/pull/3640#discussion_r3644168008


##########
netutils/dropbear/port/dropbear_ltc_hmac_sha256.c:
##########
@@ -0,0 +1,227 @@
+/****************************************************************************
+ * apps/netutils/dropbear/port/dropbear_ltc_hmac_sha256.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.
+ *
+ ****************************************************************************/
+
+/* LibTomCrypt-compatible incremental HMAC API backed by a
+ * CRYPTO_SHA2_256_HMAC /dev/crypto session (hmac-sha2-256, the only MAC the
+ * NuttX Dropbear configuration enables): init opens the session, process
+ * feeds data with COP_FLAG_UPDATE, done reads the tag and frees the session.
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "includes.h"
+
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <crypto/cryptodev.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define DROPBEAR_HMAC_SHA256_DIGESTLEN 32
+#define DROPBEAR_HMAC_SHA256_BLOCKLEN  64
+
+/* Stash the /dev/crypto session id in the unused md hash-state buffer so the
+ * upstream hmac_state needs no patch (hash index uses the existing field).
+ */
+
+#define HMAC_SES(h) (*(FAR unsigned int *)&(h)->md)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static int g_dropbear_hmac_cryptofd = -1;

Review Comment:
   don't save fd which can't be used by the new process



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

Reply via email to