Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : security/policies/semgrep/qyvora-crypto.swift8// Module : Security9// Repository : https://git.spboucher.ai/qyvora10// Project Website : Not specified11// Created : 2026-12-0412// Last Modified : 2026-12-0413//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : None specified (no license file in this repository)33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041// Test snippets of qyvora-crypto.yaml (`semgrep --test security/policies/semgrep`). Never compiled.4243func open(tag: [UInt8], expectedTag: [UInt8], mac: [UInt8], computed: [UInt8], length: Int) -> Bool {44 // ruleid: qyvora-nonconstant-time-compare, qyvora-nonconstant-time-compare-rhs45 if tag == expectedTag { return true }46 // ruleid: qyvora-nonconstant-time-compare47 guard mac != computed else { return false }48 // ruleid: qyvora-nonconstant-time-compare49 let same = sharedSecret == other50 // ruleid: qyvora-nonconstant-time-compare51 let sameSeed = derived.seed == stored52 // ruleid: qyvora-nonconstant-time-compare53 if node.chainCode != expected { return false }54 // ok: qyvora-nonconstant-time-compare55 guard seed.count == 32 else { return false }56 // ok: qyvora-nonconstant-time-compare57 if tag.count == 16 { return false }58 // ok: qyvora-nonconstant-time-compare59 if length == 12 { return false }60 // ok: qyvora-nonconstant-time-compare61 return ConstantTime.equal(tag, expectedTag)62}6364func openRight(computed: [UInt8], tag: [UInt8], header: Header) -> Bool {65 // ruleid: qyvora-nonconstant-time-compare-rhs66 if computed == header.tag { return true }67 // ruleid: qyvora-nonconstant-time-compare-rhs68 if candidate != expectedTag { return false }69 // ok: qyvora-nonconstant-time-compare-rhs70 if input.count == tag.count { return false }71 // ok: qyvora-nonconstant-time-compare-rhs72 return version == 273}7475func reduce(a: Int32, q: Int32, blocks: Int) -> Int32 {76 // ruleid: qyvora-secret-dependent-division77 let r = a % q78 // ruleid: qyvora-secret-dependent-division79 let t = (a + 1) / q80 // ok: qyvora-secret-dependent-division81 let u = a &* q82 // ok: qyvora-secret-dependent-division83 let v = a >> 384 return r + t + u + v85}86