Skip to contentSkip to conversation

php: libsodium support

PATCH New Pascal de Bruijn 2 participants 6 messages Nov 8, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 php: libsodium support

---
 package/php/Config.ext | 6 ++++++
 package/php/php.mk     | 5 +++++
 2 files changed, 11 insertions(+)
package/php/Config.ext +6 -0
index c7f0332fd8..0c6ed4b401 100644
@@ -70,6 +70,12 @@ config BR2_PACKAGE_PHP_EXT_HASH
 	help
 	  HASH message digest framework
 
+config BR2_PACKAGE_PHP_EXT_LIBSODIUM
+	bool "libsodium"
+	select BR2_PACKAGE_LIBSODIUM
+	help
+	  libsodium support
+
 config BR2_PACKAGE_PHP_EXT_MCRYPT
 	bool "mcrypt"
 	select BR2_PACKAGE_LIBMCRYPT
package/php/php.mk +5 -0
index b679531238..85bf2075ae 100644
@@ -122,6 +122,11 @@ PHP_CONF_OPTS += \
 	$(if $(BR2_PACKAGE_PHP_EXT_MBSTRING),--enable-mbstring) \
 	$(if $(BR2_PACKAGE_PHP_EXT_PHAR),--enable-phar)
 
+ifeq ($(BR2_PACKAGE_PHP_EXT_LIBSODIUM),y)
+PHP_CONF_OPTS += --with-sodium=$(STAGING_DIR)/usr
+PHP_DEPENDENCIES += libsodium
+endif
+
 ifeq ($(BR2_PACKAGE_PHP_EXT_MCRYPT),y)
 PHP_CONF_OPTS += --with-mcrypt=$(STAGING_DIR)/usr
 PHP_DEPENDENCIES += libmcrypt
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 libargon2: add new package

---
 package/Config.in                             |  1 +
 ...argon2-dont-fail-on-existing-symlink.patch | 12 +++++++
 .../0002-libargon2-fix-cross-compile.patch    | 34 +++++++++++++++++++
 package/libargon2/Config.in                   |  6 ++++
 package/libargon2/libargon2.hash              |  3 ++
 package/libargon2/libargon2.mk                | 25 ++++++++++++++
 6 files changed, 81 insertions(+)
 create mode 100644 package/libargon2/0001-libargon2-dont-fail-on-existing-symlink.patch
 create mode 100644 package/libargon2/0002-libargon2-fix-cross-compile.patch
 create mode 100644 package/libargon2/Config.in
 create mode 100644 package/libargon2/libargon2.hash
 create mode 100644 package/libargon2/libargon2.mk
package/Config.in +1 -0
index f72c77b416..694f985bec 100644
@@ -1253,6 +1253,7 @@ menu "Crypto"
 	source "package/libscrypt/Config.in"
 	source "package/libsecret/Config.in"
 	source "package/libsha1/Config.in"
+	source "package/libargon2/Config.in"
 	source "package/libsodium/Config.in"
 	source "package/libssh/Config.in"
 	source "package/libssh2/Config.in"
package/libargon2/0001-libargon2-dont-fail-on-existing-symlink.patch new file +12 -0
new file mode 100644
index 0000000000..1a65486554
@@ -0,0 +1,12 @@
+diff -Nurpd a/Makefile b/Makefile
+--- a/Makefile	2017-12-27 20:56:31.000000000 +0100
++++ b/Makefile	2019-11-07 09:52:49.554284682 +0100
+@@ -176,7 +176,7 @@ install: $(RUN) libs
+ 	$(INSTALL) -d $(INST_LIBRARY)
+ 	$(INSTALL) $(LIBRARIES) $(INST_LIBRARY)
+ ifdef LINKED_LIB_SH
+-	cd $(INST_LIBRARY) && ln -s $(notdir $(LIB_SH) $(LINKED_LIB_SH))
++	cd $(INST_LIBRARY) && ln -sf $(notdir $(LIB_SH) $(LINKED_LIB_SH))
+ endif
+ 	$(INSTALL) -d $(INST_BINARY)
+ 	$(INSTALL) $(RUN) $(INST_BINARY)
package/libargon2/0002-libargon2-fix-cross-compile.patch new file +34 -0
new file mode 100644
index 0000000000..b50b8ddb52
@@ -0,0 +1,34 @@
+From cd1c1d8d204e4ec4557e358013567c097cb70562 Mon Sep 17 00:00:00 2001
+From: Vika <[email protected]>
+Date: Mon, 26 Aug 2019 14:05:22 +0300
+Subject: [PATCH] Fix cross-compilation on some systems
+
+Some Linux distributions (e.g. NixOS, where this issue was spotted) don't provide an unprefixed ar when cross-compiling. This PR aims to fix this.
+
+See[NixOS/nixpkgs#67490](https://github.com/NixOS/nixpkgs/pull/67490) for information on where did it start.
+---
+ Makefile | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 837e7f7..38f16fc 100644
+--- a/Makefile
++++ b/Makefile
+@@ -123,6 +123,8 @@ ifdef LINKED_LIB_EXT
+ LINKED_LIB_SH := lib$(LIB_NAME).$(LINKED_LIB_EXT)
+ endif
+ 
++# Some systems don't provide an unprefixed ar when cross-compiling.
++AR=ar
+ 
+ LIBRARIES = $(LIB_SH) $(LIB_ST)
+ HEADERS = include/argon2.h
+@@ -182,7 +184,7 @@ $(LIB_SH): 	$(SRC)
+ 		$(CC) $(CFLAGS) $(LIB_CFLAGS) $(LDFLAGS) $(SO_LDFLAGS) $^ -o $@
+ 
+ $(LIB_ST): 	$(OBJ)
+-		ar rcs $@ $^
++		$(AR) rcs $@ $^
+ 
+ .PHONY: clean
+ clean:
package/libargon2/Config.in new file +6 -0
new file mode 100644
index 0000000000..1f9a5f435f
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_LIBARGON2
+	bool "libargon2"
+	help
+	  A modern pass hashing algorithm
+
+	  https://password-hashing.net/#argon2
package/libargon2/libargon2.hash new file +3 -0
new file mode 100644
index 0000000000..43fdb5467b
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256 eaea0172c1f4ee4550d1b6c9ce01aab8d1ab66b4207776aa67991eb5872fdcd8  libargon2-20171227.tar.gz
+
package/libargon2/libargon2.mk new file +25 -0
new file mode 100644
index 0000000000..204af49148
@@ -0,0 +1,25 @@
+################################################################################
+#
+# libargon2
+#
+################################################################################
+
+LIBARGON2_VERSION = 20171227		# 20190702 is not recognized by php7.3
+LIBARGON2_SITE = $(call github,P-H-C,phc-winner-argon2,$(LIBARGON2_VERSION))
+LIBARGON2_LICENSE = CC0
+LIBARGON2_LICENSE_FILES = LICENSE
+LIBARGON2_INSTALL_STAGING = YES
+
+define LIBARGON2_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D) OPTTARGET=$(GCC_TARGET_ARCH)
+endef
+
+define LIBARGON2_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D) DESTDIR=$(STAGING_DIR) install
+endef
+
+define LIBARGON2_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D) DESTDIR=$(TARGET_DIR) install
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/3 libargon2: add new package

Hello Pascal,

Quoted 1 line · On Fri, 8 Nov 2019 09:21:11 +0100 Pascal de Bruijn <[email protected]>…

---

We need your Signed-off-by.

Quoted 7 lines
 package/Config.in                             |  1 +
 ...argon2-dont-fail-on-existing-symlink.patch | 12 +++++++
 .../0002-libargon2-fix-cross-compile.patch    | 34 +++++++++++++++++++
 package/libargon2/Config.in                   |  6 ++++
 package/libargon2/libargon2.hash              |  3 ++
 package/libargon2/libargon2.mk                | 25 ++++++++++++++
 6 files changed, 81 insertions(+)

Could you add an entry in the DEVELOPERS file for this new package ?

Quoted 8 lines
package/libargon2/0001-libargon2-dont-fail-on-existing-symlink.patch new file +2 -0
new file mode 100644
index 0000000000..1a65486554
@@ -0,0 +1,12 @@
+diff -Nurpd a/Makefile b/Makefile
+--- a/Makefile	2017-12-27 20:56:31.000000000 +0100

package/libargon2/0001-libargon2-dont-fail-on-existing-symlink.patch line 12

Quoted 10 lines
package/libargon2/0001-libargon2-dont-fail-on-existing-symlink.patch new file +10 -0
++++ b/Makefile	2019-11-07 09:52:49.554284682 +0100
+@@ -176,7 +176,7 @@ install: $(RUN) libs
+ 	$(INSTALL) -d $(INST_LIBRARY)
+ 	$(INSTALL) $(LIBRARIES) $(INST_LIBRARY)
+ ifdef LINKED_LIB_SH
+-	cd $(INST_LIBRARY) && ln -s $(notdir $(LIB_SH) $(LINKED_LIB_SH))
++	cd $(INST_LIBRARY) && ln -sf $(notdir $(LIB_SH) $(LINKED_LIB_SH))
+ endif
+ 	$(INSTALL) -d $(INST_BINARY)
+ 	$(INSTALL) $(RUN) $(INST_BINARY)

Since the project is maintained with Git, please use patches generated with "git format-patch", with a proper commit log and Signed-off-by.

Also, make sure to submit this patch to the upstream project.

Quoted 6 lines
package/libargon2/0002-libargon2-fix-cross-compile.patch new file +0 -0
new file mode 100644
index 0000000000..b50b8ddb52

package/libargon2/0002-libargon2-fix-cross-compile.patch line 8

Quoted 8 lines
package/libargon2/0002-libargon2-fix-cross-compile.patch new file +8 -0
@@ -0,0 +1,34 @@
+From cd1c1d8d204e4ec4557e358013567c097cb70562 Mon Sep 17 00:00:00 2001
+From: Vika <[email protected]>
+Date: Mon, 26 Aug 2019 14:05:22 +0300
+Subject: [PATCH] Fix cross-compilation on some systems
+
+Some Linux distributions (e.g. NixOS, where this issue was spotted) don't provide an unprefixed ar when cross-compiling. This PR aims to fix this.
+
+See[NixOS/nixpkgs#67490](https://github.com/NixOS/nixpkgs/pull/67490) for information on where did it start.

Please add your Signed-off-by here.

Quoted 32 lines
package/libargon2/0002-libargon2-fix-cross-compile.patch new file +26 -0
+---
+ Makefile | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 837e7f7..38f16fc 100644
+--- a/Makefile
++++ b/Makefile
+@@ -123,6 +123,8 @@ ifdef LINKED_LIB_EXT
+ LINKED_LIB_SH := lib$(LIB_NAME).$(LINKED_LIB_EXT)
+ endif
+ 
++# Some systems don't provide an unprefixed ar when cross-compiling.
++AR=ar
+ 
+ LIBRARIES = $(LIB_SH) $(LIB_ST)
+ HEADERS = include/argon2.h
+@@ -182,7 +184,7 @@ $(LIB_SH): 	$(SRC)
+ 		$(CC) $(CFLAGS) $(LIB_CFLAGS) $(LDFLAGS) $(SO_LDFLAGS) $^ -o $@
+ 
+ $(LIB_ST): 	$(OBJ)
+-		ar rcs $@ $^
++		$(AR) rcs $@ $^
+ 
+ .PHONY: clean
+ clean:
package/libargon2/Config.in new file +0 -0
new file mode 100644
index 0000000000..1f9a5f435f

package/libargon2/Config.in line 2

Quoted 2 lines
package/libargon2/Config.in new file +2 -0
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_LIBARGON2
+	bool "libargon2"

No dependencies on toolchain features? Could you test this package with ./utils/test-pkg, just to make sure it builds in most configurations ?

package/libargon2/libargon2.hash line 2

Quoted 12 lines
package/libargon2/Config.in new file +4 -0
+	help
+	  A modern pass hashing algorithm
+
+	  https://password-hashing.net/#argon2
package/libargon2/libargon2.hash new file +2 -0
new file mode 100644
index 0000000000..43fdb5467b
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256 eaea0172c1f4ee4550d1b6c9ce01aab8d1ab66b4207776aa67991eb5872fdcd8  libargon2-20171227.tar.gz

Please add a hash for the license file.

Quoted 11 lines
package/libargon2/libargon2.hash new file +1 -0
+
package/libargon2/libargon2.mk new file +4 -0
new file mode 100644
index 0000000000..204af49148
@@ -0,0 +1,25 @@
+################################################################################
+#
+# libargon2
+#

package/libargon2/libargon2.mk line 14

Quoted 10 lines
package/libargon2/libargon2.mk new file +10 -0
+################################################################################
+
+LIBARGON2_VERSION = 20171227		# 20190702 is not recognized by php7.3
+LIBARGON2_SITE = $(call github,P-H-C,phc-winner-argon2,$(LIBARGON2_VERSION))
+LIBARGON2_LICENSE = CC0
+LIBARGON2_LICENSE_FILES = LICENSE
+LIBARGON2_INSTALL_STAGING = YES
+
+define LIBARGON2_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D) OPTTARGET=$(GCC_TARGET_ARCH)

Could you give some details about the values expected for OPTTARGET ? Indeed, GCC_TARGET_ARCH only has a value on MIPS, NDS32, x86 and RISC-V. On all other architectures, it is empty as far as I can see. So I am really not sure GCC_TARGET_ARCH is what you want here.

package/libargon2/libargon2.mk line 23

Quoted 7 lines
package/libargon2/libargon2.mk new file +7 -0
+define LIBARGON2_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D) DESTDIR=$(STAGING_DIR) install
+endef
+
+define LIBARGON2_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D) DESTDIR=$(TARGET_DIR) install
+endef

In all these commands, I suppose you have used $(MAKE1) because you faced some parallel build issues with this package ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 3/3 php: libargon2 support

In reply to Pascal de Bruijn
---
 package/php/Config.ext | 6 ++++++
 package/php/php.mk     | 5 +++++
 2 files changed, 11 insertions(+)
package/php/Config.ext +6 -0
index 0c6ed4b401..d5c723ca39 100644
@@ -70,6 +70,12 @@ config BR2_PACKAGE_PHP_EXT_HASH
 	help
 	  HASH message digest framework
 
+config BR2_PACKAGE_PHP_EXT_LIBARGON2
+	bool "libargon2"
+	select BR2_PACKAGE_LIBARGON2
+	help
+	  libargon2 support
+
 config BR2_PACKAGE_PHP_EXT_LIBSODIUM
 	bool "libsodium"
 	select BR2_PACKAGE_LIBSODIUM
package/php/php.mk +5 -0
index 85bf2075ae..007b8a64c3 100644
@@ -122,6 +122,11 @@ PHP_CONF_OPTS += \
 	$(if $(BR2_PACKAGE_PHP_EXT_MBSTRING),--enable-mbstring) \
 	$(if $(BR2_PACKAGE_PHP_EXT_PHAR),--enable-phar)
 
+ifeq ($(BR2_PACKAGE_PHP_EXT_LIBARGON2),y)
+PHP_CONF_OPTS += --with-password-argon2=$(STAGING_DIR)/usr
+PHP_DEPENDENCIES += libargon2
+endif
+
 ifeq ($(BR2_PACKAGE_PHP_EXT_LIBSODIUM),y)
 PHP_CONF_OPTS += --with-sodium=$(STAGING_DIR)/usr
 PHP_DEPENDENCIES += libsodium
Signature · 1 line
2.17.1
#4 lore raw

PATCH 3/3 php: libargon2 support

Quoted 1 line · On Fri, 8 Nov 2019 09:21:12 +0100 Pascal de Bruijn <[email protected]>…

---

Looks good, but we will need your Signed-off-by in the commit log as well.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH 1/3 php: libsodium support

In reply to Pascal de Bruijn
Quoted 1 line · On Fri, 8 Nov 2019 09:21:10 +0100 Pascal de Bruijn <[email protected]>…

---

Patch looks good, but we need your Signed-off-by line to be able to apply the patch.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com