Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision ae06d3dfc39e62f24a6dbb62d8e15a198b536d29 authored by Matthias J. Kannwischer on 31 January 2019, 10:15:17 UTC, committed by Joost Rijneveld on 31 January 2019, 10:15:17 UTC
Add kyber512 and kyber1024 (#35)
* add kyber512 and kyber1024 ref

* add m4 optimized kyber512 and kyber1024

* add kyber512 and kyber1024 benchmarks
1 parent c589096
  • Files
  • Changes
  • 0f0e6f5
  • /
  • utils.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:ae06d3dfc39e62f24a6dbb62d8e15a198b536d29
directory badge
swh:1:dir:0f0e6f57638ca1490f87065c51561ec2d36d88b1
content badge
swh:1:cnt:e3790a14bec38aacdcdce12983dcd5f1c1ff04c5

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
utils.py
import os
import serial
import subprocess
import sys
import string

dev = serial.Serial("/dev/ttyUSB0", 115200,timeout=10)

def m4run(binpath):
    print("Flashing {}..".format(binpath))
    rc = subprocess.run(["st-flash", "--reset",  "write", binpath, "0x8000000"],
                   stdout=sys.stdout.buffer, stderr=sys.stdout.buffer)

    if rc.returncode != 0:
        raise Exception("Flashing failed.")

    state = 'waiting'
    marker = b''
    # This parses test vector output starting with a number of leading '=',
    #  and expects a hashtag '#' after the test vector output.
    while True:
        x = dev.read()
        if x == b'' and state == 'waiting':
            print("timed out while waiting for the markers")
            m4run(binpath)
            return

        if state == 'waiting':
            if x == b'=':
                marker += x
                continue
            # If we saw at least 5 equal signs, assume we've probably started
            elif marker.count(b'=') > 5:
                state = 'beginning'
                vector = []
                print("  .. found output marker..")
        if state == 'beginning':
            if x == b'=':
                continue
            else:
                state = 'reading'
        elif state == 'reading':
            if x == b'#':
                break
            else:
                vector.append(x)
    output = b''.join(vector).decode('utf-8', 'ignore')
    # sometimes there's a line full of markers; strip that out to avoid errors
    lines = [x for x in output.split('\n') if not all(c == '=' for c in x)]
    return '\n'.join(lines) + '\n'

def m4ignore(primitive, scheme, implementation):
    ignores = [os.path.join(primitive, scheme, implementation, '.m4ignore'),
               os.path.join(primitive, scheme, '.m4ignore'),
               os.path.join(primitive, '.m4ignore')]
    return any(os.path.exists(path) for path in ignores)
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API