// Code generated by rsagen, DO NOT EDIT.
//
{{ range .InputLines -}}
// {{ printf "%s" . }}
{{ end -}}
//

package {{ .Package }}

import (
	"crypto/rsa"
	"math/big"
)

var _ = (*big.Int)(nil)

{{ define "chunks" -}}
	{{- range chunks . 8 }}
		{{ range . }}{{ printf "%#02x" . }},{{ end }}
	{{- end }}
{{- end }}

{{ define "bigint-positive" -}}
	new(big.Int).SetBytes([]byte{
		{{- template "chunks" .Bytes }}
	})
{{- end }}

{{ define "bigint" }}
	{{- if eq .Sign -1 -}} new(big.Int).Neg( {{- end -}}
	{{- template "bigint-positive" . -}}
	{{- if eq .Sign -1 -}} ) {{- end -}}
{{ end }}

{{ define "pubkey" -}}
	&rsa.PublicKey{
		E: {{ .E }},
		N: {{ template "bigint" .N }},
	}
{{- end }}

{{ if not .Single }}
	var {{ .Variable }} = []*rsa.PublicKey{
		{{- range .Keys }}
			{{ template "pubkey" . }}, // Fingerprint: {{ fingerprint . }}
		{{- end }}
	}
{{ else }}
	var {{ .Variable }} = {{ template "pubkey" (single .Keys) }} // Fingerprint: {{ single .Keys | fingerprint }}
{{ end }}
