OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // This package parses X.509-encoded keys and certificates. | 5 // This package parses X.509-encoded keys and certificates. |
6 package x509 | 6 package x509 |
7 | 7 |
8 import ( | 8 import ( |
9 "asn1" | 9 "asn1" |
10 "big" | 10 "big" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 digest := h.Sum() | 400 digest := h.Sum() |
401 | 401 |
402 return rsa.VerifyPKCS1v15(pub, hashType, digest, c.Signature) | 402 return rsa.VerifyPKCS1v15(pub, hashType, digest, c.Signature) |
403 } | 403 } |
404 | 404 |
405 func matchHostnames(pattern, host string) bool { | 405 func matchHostnames(pattern, host string) bool { |
406 if len(pattern) == 0 || len(host) == 0 { | 406 if len(pattern) == 0 || len(host) == 0 { |
407 return false | 407 return false |
408 } | 408 } |
409 | 409 |
410 » patternParts := strings.Split(pattern, ".", 0) | 410 » patternParts := strings.Split(pattern, ".", -1) |
411 » hostParts := strings.Split(host, ".", 0) | 411 » hostParts := strings.Split(host, ".", -1) |
412 | 412 |
413 if len(patternParts) != len(hostParts) { | 413 if len(patternParts) != len(hostParts) { |
414 return false | 414 return false |
415 } | 415 } |
416 | 416 |
417 for i, patternPart := range patternParts { | 417 for i, patternPart := range patternParts { |
418 if patternPart == "*" { | 418 if patternPart == "*" { |
419 continue | 419 continue |
420 } | 420 } |
421 if patternPart != hostParts[i] { | 421 if patternPart != hostParts[i] { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 return | 811 return |
812 } | 812 } |
813 | 813 |
814 cert, err = asn1.MarshalToMemory(certificate{ | 814 cert, err = asn1.MarshalToMemory(certificate{ |
815 c, | 815 c, |
816 algorithmIdentifier{oidSHA1WithRSA}, | 816 algorithmIdentifier{oidSHA1WithRSA}, |
817 asn1.BitString{Bytes: signature, BitLength: len(signature) * 8}, | 817 asn1.BitString{Bytes: signature, BitLength: len(signature) * 8}, |
818 }) | 818 }) |
819 return | 819 return |
820 } | 820 } |
OLD | NEW |