Skip to content
Permalink
Browse files

Fix all but the lock dialyzer issue

  • Loading branch information...
fhunleth committed Dec 5, 2018
1 parent 6a1db19 commit 963b0d2dc264dbdb17752e63208612121ca3b108
Showing with 17 additions and 19 deletions.
  1. +2 −0 dialyzer.ignore-warnings
  2. +6 −4 lib/nerves_key.ex
  3. +3 −14 lib/nerves_key/data.ex
  4. +5 −0 lib/nerves_key/provisioning_info.ex
  5. +1 −1 mix.exs
@@ -1,5 +1,7 @@
:0: Unknown type 'Elixir.X509.ASN1':record/1
:0: Unknown type public_key:ec_private_key/0
:0: Unknown type public_key:ec_public_key/0
:0: Unknown type public_key:rsa_private_key/0
:0: Unknown type public_key:rsa_public_key/0
:0: Unknown type public_key:issuer_name/0

@@ -40,7 +40,7 @@ defmodule NervesKey do
def provision(transport, info, signer_cert, signer_key) do
:ok = configure(transport)
otp_info = OTP.new(info.board_name, info.manufacturer_sn)
otp_data = OTP.to_raw(info)
otp_data = OTP.to_raw(otp_info)
# :ok = OTP.write(transport, otp)
{:ok, device_public_key} = Data.genkey(transport)
{:ok, device_sn} = Config.device_sn(transport)
@@ -54,10 +54,12 @@ defmodule NervesKey do
signer_key
)

:ok = Data.write_certificates(transport, device_cert, signer_cert)
slot_data = Data.slot_data(device_sn, device_cert, signer_cert)

:ok = Data.write_slots(transport, slot_data)

device_cert
# No turning back!!
# :ok = Data.lock(transport)
# :ok = Data.lock(transport, otp_data, slot_data)
{device_cert, otp_data, slot_data}
end
end
@@ -3,19 +3,6 @@ defmodule NervesKey.Data do
This module handles Data Zone data stored in the Nerves Key.
"""

# @doc """
# Read the device certificate
# """
# @spec read_device_certificate(Transport.t()) :: {:ok, X509.Certificate.t()} | {:error, atom()}
# def read_device_certificate(transport) do
# with {:ok, compressed_cert} <- DataZone.read(transport, 10),
# {:ok, public_key} <- Request.genkey(transport, 0, false),

# do
# cert = ATECC508A.Certificate.decompress(compressed_cert, public_key)
# end
# end

@doc """
Create a public/private key pair
@@ -68,6 +55,8 @@ defmodule NervesKey.Data do
@doc """
Write all of the slots
"""
@spec write_slots(ATECC508A.Transport.t(), [{ATECC508A.Request.slot(), binary()}]) ::
:ok | {:error, atom()}
def write_slots(transport, slot_data) do
Enum.each(slot_data, fn {slot, data} ->
:ok = ATECC508A.DataZone.write_padded(transport, slot, data)
@@ -79,7 +68,7 @@ defmodule NervesKey.Data do

# There's no going back!
# """
@spec lock(ATECC508A.Transport.t(), binary(), [{Request.slot(), binary()}]) ::
@spec lock(ATECC508A.Transport.t(), binary(), [{ATECC508A.Request.slot(), binary()}]) ::
:ok | {:error, atom()}
def lock(transport, otp_data, slot_data) do
sorted_slot_data =
@@ -1,3 +1,8 @@
defmodule NervesKey.ProvisioningInfo do
defstruct [:manufacturer_sn, :board_name]

@type t :: %__MODULE__{
manufacturer_sn: binary(),
board_name: binary()
}
end
@@ -14,7 +14,7 @@ defmodule Atecc508a.MixProject do
docs: [extras: ["README.md"], main: "readme"],
deps: deps(),
dialyzer: [
plt_add_apps: [:public_key, :asn1, :crypto],
plt_add_apps: [:public_key, :asn1, :crypto, :mix],
ignore_warnings: "dialyzer.ignore-warnings"
]
]

0 comments on commit 963b0d2

Please sign in to comment.
You can’t perform that action at this time.