|
|
@@ -11,6 +11,7 @@ type Security struct {
|
|
11
|
11
|
KeyMap map[string]string
|
|
12
|
12
|
}
|
|
13
|
13
|
|
|
|
14
|
+//Security 생성자
|
|
14
|
15
|
func NewSecurity() *Security {
|
|
15
|
16
|
security := &Security{map[string]string{}}
|
|
16
|
17
|
fmt.Println("security setting complete.")
|
|
|
@@ -28,7 +29,7 @@ type SecurityManager interface {
|
|
28
|
29
|
//CompareAlpha(topic1 []int64, topic2 []int64) int
|
|
29
|
30
|
}
|
|
30
|
31
|
|
|
31
|
|
-/**
|
|
|
32
|
+/*
|
|
32
|
33
|
keyShareMsg 에서 각 노드의 private 키를 받아 keyMap 에 저장
|
|
33
|
34
|
*/
|
|
34
|
35
|
func (sc Security) RegKey(rm RegisterMsg) {
|
|
|
@@ -48,7 +49,7 @@ func (sc Security) GetNodeKey(nodeName string) int64 {
|
|
48
|
49
|
return mKey
|
|
49
|
50
|
}
|
|
50
|
51
|
|
|
51
|
|
-/**
|
|
|
52
|
+/*
|
|
52
|
53
|
reEncrypt 해서 슬라이스 반환
|
|
53
|
54
|
*/
|
|
54
|
55
|
func (sc Security) ReEncrypt(fromKey int64, toKey int64, target []int64) []int64 {
|
|
|
@@ -83,6 +84,7 @@ func (sc Security) ReEncPubMsg(fromPubMsg PublishMsg, nodeName string) PublishMs
|
|
83
|
84
|
return toPubMsg
|
|
84
|
85
|
}
|
|
85
|
86
|
|
|
|
87
|
+//Key제거 함수
|
|
86
|
88
|
func (sc *Security) RemoveSecureKey(nodeName string) bool {
|
|
87
|
89
|
//삭제 전 존재여부 확인
|
|
88
|
90
|
_, exists := sc.KeyMap[nodeName]
|
|
|
@@ -95,46 +97,3 @@ func (sc *Security) RemoveSecureKey(nodeName string) bool {
|
|
95
|
97
|
return false
|
|
96
|
98
|
}
|
|
97
|
99
|
}
|
|
98
|
|
-
|
|
99
|
|
-/**
|
|
100
|
|
-Compare 함수들은 같으면 0 다르면 -1 (비교가 필요한 경우 오름차순 1 내림차순 -1)
|
|
101
|
|
-*/
|
|
102
|
|
-//func (sc Security) CompareTopic(topic1 []int64, topic2 []int64) int {
|
|
103
|
|
-// // 길이 같은지 체크
|
|
104
|
|
-// if len(topic1) != len(topic2) {
|
|
105
|
|
-// return -1
|
|
106
|
|
-// }
|
|
107
|
|
-// for i := 0; i < len(topic2); i++ {
|
|
108
|
|
-// if topic1[i] != topic2[i] {
|
|
109
|
|
-// return -1
|
|
110
|
|
-// }
|
|
111
|
|
-// }
|
|
112
|
|
-// return 0
|
|
113
|
|
-//}
|
|
114
|
|
-//
|
|
115
|
|
-//func (sc Security) CompareDigit(topic1 int64, topic2 int64) int {
|
|
116
|
|
-// if topic1 < topic2 {
|
|
117
|
|
-// return 1
|
|
118
|
|
-// } else if topic1 > topic2 {
|
|
119
|
|
-// return -1
|
|
120
|
|
-// }
|
|
121
|
|
-// return 0
|
|
122
|
|
-//}
|
|
123
|
|
-//
|
|
124
|
|
-//func (sc Security) CompareAlpha(topic1 []int64, topic2 []int64) int {
|
|
125
|
|
-// // 길이 같은지 체크
|
|
126
|
|
-// if len(topic1) != len(topic2) {
|
|
127
|
|
-// return -1
|
|
128
|
|
-// }
|
|
129
|
|
-// for i := 0; i < len(topic2); i++ {
|
|
130
|
|
-// if topic1[i] != topic2[i] {
|
|
131
|
|
-// return -1
|
|
132
|
|
-// }
|
|
133
|
|
-// }
|
|
134
|
|
-// return 0
|
|
135
|
|
-//}
|
|
136
|
|
-
|
|
137
|
|
-// private key 생성 메세지
|
|
138
|
|
-//func (sc Security) keyGenPrivate() KeyGenMsg{
|
|
139
|
|
-//
|
|
140
|
|
-//}
|