You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
784 B

  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "net/http"
  6. ownrsa "./ownrsa"
  7. )
  8. //generate key pair
  9. //blind m
  10. //unblind m
  11. func Index(w http.ResponseWriter, r *http.Request) {
  12. fmt.Fprintln(w, "serverIDsigner")
  13. }
  14. func IDs(w http.ResponseWriter, r *http.Request) {
  15. //read the keys stored in /keys directory
  16. keys := readKeys("keys.json")
  17. saveKeys(keys, "keys.json")
  18. jResp, err := json.Marshal(keys)
  19. check(err)
  20. fmt.Fprintln(w, string(jResp))
  21. }
  22. func NewID(w http.ResponseWriter, r *http.Request) {
  23. //generate RSA keys pair
  24. newKey := ownrsa.GenerateKeyPair()
  25. key := ownrsa.PackKey(newKey)
  26. fmt.Println(key)
  27. keys := readKeys("keys.json")
  28. keys = append(keys, key)
  29. saveKeys(keys, "keys.json")
  30. jResp, err := json.Marshal(keys)
  31. check(err)
  32. fmt.Fprintln(w, string(jResp))
  33. }