From 35f7fe6717b0373241db01318ce68c449a2b9df1 Mon Sep 17 00:00:00 2001 From: Caleb Xu Date: Fri, 17 Jan 2025 14:18:35 -0500 Subject: [PATCH 1/2] libcotp 3.1.0 (new formula) --- .github/autobump.txt | 1 + Formula/lib/libcotp.rb | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Formula/lib/libcotp.rb diff --git a/.github/autobump.txt b/.github/autobump.txt index e8193adf65c61..91386c4b195e4 100644 --- a/.github/autobump.txt +++ b/.github/autobump.txt @@ -1693,6 +1693,7 @@ libcdr libchewing libclc libcoap +libcotp libcouchbase libcpuid libcss diff --git a/Formula/lib/libcotp.rb b/Formula/lib/libcotp.rb new file mode 100644 index 0000000000000..0365c6dcdd48f --- /dev/null +++ b/Formula/lib/libcotp.rb @@ -0,0 +1,47 @@ +class Libcotp < Formula + desc "C library that generates TOTP and HOTP" + homepage "https://github.com/paolostivanin/libcotp" + url "https://github.com/paolostivanin/libcotp/archive/refs/tags/v3.1.0.tar.gz" + sha256 "a48bbfd95b7ec12d23e4e2c4a017f8acddecc14bf10541ff144563cee044b39c" + license "Apache-2.0" + head "https://github.com/paolostivanin/libcotp.git", branch: "master" + + depends_on "cmake" => :build + depends_on "pkgconf" => :build + depends_on "libgcrypt" + + def install + system "cmake", "-S", ".", "-B", "build", *std_cmake_args + system "cmake", "--build", "build" + system "cmake", "--install", "build" + end + + test do + (testpath/"test.c").write <<~C + #include + #include + #include + #include + + int main() { + const char *K = "12345678901234567890"; + const int64_t counter[] = {59, 1111111109, 1111111111, 1234567890, 2000000000, 20000000000}; + + cotp_error_t cotp_err; + char *K_base32 = base32_encode((const uchar *)K, strlen(K)+1, &cotp_err); + + cotp_error_t err; + for (int i = 0; i < 6; i++) { + printf("%s\\n", get_totp_at(K_base32, counter[i], 8, 30, SHA1, &err)); + } + + free(K_base32); + return 0; + } + C + system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lcotp", "-o", "test" + + expected_output = %w[94287082 07081804 14050471 89005924 69279037 65353130] + assert_equal expected_output, shell_output("./test").split("\n") + end +end From 6d3884f7eb038d33de85329fe9acf0b74a188a14 Mon Sep 17 00:00:00 2001 From: Daeho Ro Date: Sat, 18 Jan 2025 02:42:13 +0000 Subject: [PATCH 2/2] libcotp: add 3.1.0 bottle. --- Formula/lib/libcotp.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Formula/lib/libcotp.rb b/Formula/lib/libcotp.rb index 0365c6dcdd48f..22621c8b43f20 100644 --- a/Formula/lib/libcotp.rb +++ b/Formula/lib/libcotp.rb @@ -6,6 +6,15 @@ class Libcotp < Formula license "Apache-2.0" head "https://github.com/paolostivanin/libcotp.git", branch: "master" + bottle do + sha256 cellar: :any, arm64_sequoia: "a55767669aadfbc33ca5047a9bf5a1371ebaf4ccb3c9e3e14a3296516f0702e9" + sha256 cellar: :any, arm64_sonoma: "3c1f7d889c8212c2a7e8763c9bc712ce98ce0e8cd2520a27e6ed13468bdfa922" + sha256 cellar: :any, arm64_ventura: "626c19565338f9e6ebf991ffdb7c7acb0beea6fb5ce65317ea12a08cdaea63d8" + sha256 cellar: :any, sonoma: "6a56e1465c12f7f4a88da73e4feb96255e03b2739a4a9e2d7fe176c9a9290960" + sha256 cellar: :any, ventura: "540f3a6ecfea711699139ec94e16bf0e194094a0508e7e111777632c637388b9" + sha256 cellar: :any_skip_relocation, x86_64_linux: "bc3ff644b09e647890b68df9d726edcc2a8d18e293cc4773d921141147a6ffc4" + end + depends_on "cmake" => :build depends_on "pkgconf" => :build depends_on "libgcrypt"